// This file is a part of the Framsticks GDK. // Copyright (C) 1999-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. // Refer to http://www.framsticks.com/ for further information. #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 //this #include must be present before two #defines below can be used, otherwise one will see: '_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 #ifndef __CYGWIN__ #define stricmp(a,b) strcasecmp(a,b) #endif #endif #ifdef MACOS #define stricmp(a,b) strcasecmp(a,b) #endif #ifdef IPHONE #include std::string getAppHome(); std::string getAppResources(); #define GET_APP_HOME getAppHome() #define GET_APP_RESOURCES getAppResources() #endif #ifdef SHP #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 #ifdef LINUX #define GET_APP_HOME "./" #define GET_APP_RESOURCES "./" #endif #if defined(_WIN32) && !defined(SHP) #define GET_APP_HOME ".\\" #define GET_APP_RESOURCES ".\\" #endif #ifdef INITIAL_DIR_IS_HOME #include "cwd.h" #ifdef GET_APP_HOME #undef GET_APP_HOME #endif #define GET_APP_HOME getAppHome() #endif #ifdef INITIAL_DIR_IS_RES #include "cwd.h" #ifdef GET_APP_RESOURCES #undef GET_APP_RESOURCES #endif #define GET_APP_RESOURCES getAppResources() #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