source: cpp/gdk/nonstd.h @ 95

Last change on this file since 95 was 82, checked in by Maciej Komosinski, 12 years ago

compiles under more platforms and OSes

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1#ifndef _NONSTD_H_
2#define _NONSTD_H_
3
4#define SAFEDELETE(p) {if (p) {delete p; p=NULL;}}
5#define SAFEDELETEARRAY(p) {if (p) {delete[] p; p=NULL;}}
6
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
13
14#define DB(x) //output debug info. If needed, use #define DB(x) x
15//#define DB(x) x
16
17
18// ms visual c++
19#ifdef _MSC_VER
20 #include <stdio.h> //musi byc najpierw ten include zeby robic definy ponizej (albo bedzie '_vsnprintf': attributes inconsistent with previous declaration, stdio.h:358)
21 #define vsnprintf _vsnprintf
22 #define snprintf _snprintf
23#endif
24
25#ifdef MOBILE2D
26 #define strdup _strdup
27#endif
28
29/////////////////////////////////////////////////////// 64-bit int type and other macros
30#ifdef _WIN32
31        typedef __int64 LONGLONG;
32        #define PATH_SEPARATOR_CHAR '\\'
33        #define PATH_SEPARATOR_STRING "\\"
34        #define FPU_THROWS_EXCEPTIONS
35        #define FOPEN_READ "rt"
36        #define FOPEN_WRITE "wt"
37        #define FOPEN_APPEND "at"
38#else
39        #define LONGLONG long long int
40        #define PATH_SEPARATOR_CHAR '/'
41        #define PATH_SEPARATOR_STRING "/"
42        #define FOPEN_READ "r"
43        #define FOPEN_WRITE "w"
44        #define FOPEN_APPEND "a"
45#endif
46
47
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 "./"
55#endif
56
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()
64#endif
65
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/"
70#endif
71
72#if defined(_WIN32) && !defined(SHP)
73    #define GET_APP_HOME ".\\"
74    #define GET_APP_RESOURCES ".\\"
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 TracBrowser for help on using the repository browser.