Changeset 82 for cpp/gdk/nonstd.h
- Timestamp:
- 02/08/13 03:44:31 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/gdk/nonstd.h
r69 r82 1 //Define rnd01, rnd0N, and randomN so that they 2 //work in your C++ environment. 3 //Some other functions/macros may also be needed if they 4 //are missing in your environment, like min, max, etc. 1 #ifndef _NONSTD_H_ 2 #define _NONSTD_H_ 5 3 6 #ifndef __NONSTD_H7 #define __NONSTD_H8 9 #define APPLICATION_NAME "Framsticks"10 #define MAIN_FRAMSTICKS11 4 #define SAFEDELETE(p) {if (p) {delete p; p=NULL;}} 12 5 #define SAFEDELETEARRAY(p) {if (p) {delete[] p; p=NULL;}} 13 6 14 //#ifndef _Windows included below? 15 //#include <stdlib.h> 16 //#endif 7 #define roundToInt(x) ((int)(floor((x)+0.5))) 8 9 10 #define CPP_STR(s) CPP_XSTR(s) 11 #define CPP_XSTR(s) #s 12 17 13 18 14 #define DB(x) //output debug info. If needed, use #define DB(x) x 19 15 //#define DB(x) x 20 16 17 21 18 // ms visual c++ 22 19 #ifdef _MSC_VER 23 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 24 #include <windows.h> 25 #include <stdio.h> 26 #include <stdarg.h> 20 #include <stdio.h> //musi byc najpierw ten include zeby robic definy ponizej (albo bedzie '_vsnprintf': attributes inconsistent with previous declaration, stdio.h:358) 27 21 #define vsnprintf _vsnprintf 28 #define _USE_MATH_DEFINES //after this is defined, the next #include <math.h> or <cmath> will define: 29 //#ifndef M_PI 30 //#define M_PI 3.1415926535897932384626433832795 31 //#endif 32 //#ifndef M_PI_2 33 //#define M_PI_2 (M_PI/2) 34 //#endif 22 #define snprintf _snprintf 23 #endif 35 24 25 #ifdef MOBILE2D 26 #define strdup _strdup 36 27 #endif 37 28 38 29 /////////////////////////////////////////////////////// 64-bit int type and other macros 39 #ifdef _W indows30 #ifdef _WIN32 40 31 typedef __int64 LONGLONG; 41 #define PATH SEPARATORCHAR '\\'42 #define PATH SEPARATORSTRING "\\"32 #define PATH_SEPARATOR_CHAR '\\' 33 #define PATH_SEPARATOR_STRING "\\" 43 34 #define FPU_THROWS_EXCEPTIONS 44 35 #define FOPEN_READ "rt" … … 47 38 #else 48 39 #define LONGLONG long long int 49 #define PATH SEPARATORCHAR '/'50 #define PATH SEPARATORSTRING "/"40 #define PATH_SEPARATOR_CHAR '/' 41 #define PATH_SEPARATOR_STRING "/" 51 42 #define FOPEN_READ "r" 52 43 #define FOPEN_WRITE "w" … … 54 45 #endif 55 46 56 #ifdef __BORLANDC__57 #define fileExists(f) (!access(f,0))58 #include "stdlib.h" //random59 #define rnd01 ((double)((double)_lrand()/(double)(LRAND_MAX+1)))60 //#define rnd01 ((double)((double)rand()/(RAND_MAX+1)))61 #define rnd0N(num) ((double)((num)*rnd01))62 #define randomN(num) random(num) //uses _lrand63 #else64 #ifdef _MSC_VER65 #define fileExists(f) (!access(f,0))66 #else67 #define fileExists(f) (!access(f,R_OK))68 #endif69 47 70 //#define FLOATRAND 71 #ifdef FLOATRAND 72 #define randomN(x) ((int)((x)*drand48())) 73 #define rnd01 (drand48()) 74 #define rnd0N(x) (drand48()*(x)) 75 #else 76 #define rnd01 ((double)(rand()/(RAND_MAX+1.0))) 77 #define rnd0N(x) ((x)*rnd01) 78 #define randomN(x) ((int)rnd0N(x)) 79 #endif 48 49 #ifdef LINUX 50 #include <strings.h> 51 #define stricmp(a,b) strcasecmp(a,b) 52 #define _isnan(a) isnan(a) //do nonstd_math.h? 53 #define GET_APP_HOME "./" 54 #define GET_APP_RESOURCES "./" 80 55 #endif 81 56 82 83 #ifdef __GNUC__ 84 /* 85 #define min(a,b) (((a)>(b))?(b):(a)) 86 #define max(a,b) (((a)>(b))?(a):(b)) 87 #define abs(a) ((a)>=0?(a):-(a)) 88 */ 89 #include <algorithm> 90 using namespace std; 57 #ifdef IPHONE 58 #include <string> 59 #define _isnan(a) isnan(a) //do nonstd_math.h? 60 std::string getAppHome(); //w tym pliku deklaracja funkcji nie pasuje... 61 std::string getAppResources(); 62 #define GET_APP_HOME getAppHome() 63 #define GET_APP_RESOURCES getAppResources() 91 64 #endif 92 65 93 #ifdef DEFINE_STRICMP_AS_STRCASECMP 94 #define stricmp(a,b) strcasecmp(a,b) 66 #ifdef SHP 67 //#define __assert_func(a,b,c,d) 0 //Currently, we are sorry to inform you that assert() is not yet supported. We have considered your request for internal discussion. No ale na szczêcie w³asna (byle by by³a, bo i tak zak³adamy ze assert ktore przeciez dziala tylko w trybie debug nie jest potrzebne na bada) implementacja w "bada-assert.cpp" 68 #define GET_APP_HOME "/Home/" 69 #define GET_APP_RESOURCES "/Res/" 95 70 #endif 96 71 72 #if defined(_WIN32) && !defined(SHP) 73 #define GET_APP_HOME ".\\" 74 #define GET_APP_RESOURCES ".\\" 97 75 #endif 76 77 //typedef unsigned char boolean; //niestety nie mozna uzyc 'bool' bo VC w rpcndr.h wlasnie tak definiuje booleana, jako unsigned char 78 //typedef char byte; //rozne srodowiska c++ definiuja byte jako unsigned char! w javie jest inaczej -> trzeba i tak zmienic w portowanych zrodlach byte na char. 79 80 #endif
Note: See TracChangeset
for help on using the changeset viewer.