#ifndef _NONSTD_H_ #define _NONSTD_H_ #define SAFEDELETE(p) {if (p) {delete p; p=NULL;}} #define SAFEDELETEARRAY(p) {if (p) {delete[] p; p=NULL;}} #define roundToInt(x) ((int)(floor((x)+0.5))) #define CPP_STR(s) CPP_XSTR(s) #define CPP_XSTR(s) #s #define DB(x) //output debug info. If needed, use #define DB(x) x //#define DB(x) x // ms visual c++ #ifdef _MSC_VER #include //musi byc najpierw ten include zeby robic definy ponizej (albo bedzie '_vsnprintf': attributes inconsistent with previous declaration, stdio.h:358) #define vsnprintf _vsnprintf #define snprintf _snprintf #endif #ifdef MOBILE2D #define strdup _strdup #endif /////////////////////////////////////////////////////// 64-bit int type and other macros #ifdef _WIN32 typedef __int64 LONGLONG; #define PATH_SEPARATOR_CHAR '\\' #define PATH_SEPARATOR_STRING "\\" #define FPU_THROWS_EXCEPTIONS #else #define LONGLONG long long int #define PATH_SEPARATOR_CHAR '/' #define PATH_SEPARATOR_STRING "/" #endif #define FOPEN_READ_BINARY "rb" // no FOPEN_READ_TEXT #define FOPEN_WRITE_BINARY "wb" #define FOPEN_APPEND_BINARY "ab" #define FOPEN_WRITE_TEXT "wt" #define FOPEN_APPEND_TEXT "at" #ifdef LINUX #include #define stricmp(a,b) strcasecmp(a,b) #define _isnan(a) isnan(a) //do nonstd_math.h? #ifdef INITIAL_DIR_IS_HOME #include "cwd.h" #define GET_APP_HOME getAppHome() #else #define GET_APP_HOME "./" #endif #ifdef INITIAL_DIR_IS_RES #include "cwd.h" #define GET_APP_RESOURCES getAppResources() #else #define GET_APP_RESOURCES "./" #endif #endif #ifdef MACOS #define stricmp(a,b) strcasecmp(a,b) #endif #ifdef IPHONE #include #define _isnan(a) isnan(a) //do nonstd_math.h? std::string getAppHome(); std::string getAppResources(); #define GET_APP_HOME getAppHome() #define GET_APP_RESOURCES getAppResources() #endif #ifdef SHP //#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" #define GET_APP_HOME "/Home/" #define GET_APP_RESOURCES "/Res/" #endif #ifdef TIZEN #define GET_APP_HOME "/data/" #define GET_APP_RESOURCES "/res/" #endif #ifdef __ANDROID__ #define GET_APP_HOME getAppHome() #define GET_APP_RESOURCES "./" //w APK trzymamy w katalogu w "assets", bo w "res" nie ma podkatalogow ani odwolywania sie po nazwach #endif #if defined(_WIN32) && !defined(SHP) #define GET_APP_HOME ".\\" #define GET_APP_RESOURCES ".\\" #endif #ifdef MAIN_FRAMSTICKS #define SCRIPTS_DIR GET_APP_RESOURCES "scripts" //katalogi sa na iphone std::string a gdzie indziej "const char*" i to sie wszedzie kompiluje? #endif //typedef unsigned char boolean; //niestety nie mozna uzyc 'bool' bo VC w rpcndr.h wlasnie tak definiuje booleana, jako unsigned char //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. #endif