1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
2 | // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski. |
---|
3 | // See LICENSE.txt for details. |
---|
4 | |
---|
5 | #ifndef _NONSTD_H_ |
---|
6 | #define _NONSTD_H_ |
---|
7 | |
---|
8 | #define SAFEDELETE(p) {if (p) {delete p; p=NULL;}} |
---|
9 | #define SAFEDELETEARRAY(p) {if (p) {delete[] p; p=NULL;}} |
---|
10 | |
---|
11 | #define roundToInt(x) ((int)(floor((x)+0.5))) |
---|
12 | |
---|
13 | |
---|
14 | #define CPP_STR(s) CPP_XSTR(s) |
---|
15 | #define CPP_XSTR(s) #s |
---|
16 | |
---|
17 | |
---|
18 | #define DB(x) //output debug info. If needed, use #define DB(x) x |
---|
19 | //#define DB(x) x |
---|
20 | |
---|
21 | |
---|
22 | // ms visual c++ |
---|
23 | #ifdef _MSC_VER |
---|
24 | #include <stdio.h> //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 |
---|
25 | #define vsnprintf _vsnprintf |
---|
26 | #define snprintf _snprintf |
---|
27 | #endif |
---|
28 | |
---|
29 | #ifdef MOBILE2D |
---|
30 | #define strdup _strdup |
---|
31 | #endif |
---|
32 | |
---|
33 | /////////////////////////////////////////////////////// 64-bit int type and other macros |
---|
34 | #ifdef _WIN32 |
---|
35 | typedef __int64 LONGLONG; |
---|
36 | #define PATH_SEPARATOR_CHAR '\\' |
---|
37 | #define PATH_SEPARATOR_STRING "\\" |
---|
38 | #define FPU_THROWS_EXCEPTIONS |
---|
39 | #else |
---|
40 | #define LONGLONG long long int |
---|
41 | #define PATH_SEPARATOR_CHAR '/' |
---|
42 | #define PATH_SEPARATOR_STRING "/" |
---|
43 | #endif |
---|
44 | |
---|
45 | #define FOPEN_READ_BINARY "rb" |
---|
46 | // no FOPEN_READ_TEXT |
---|
47 | #define FOPEN_WRITE_BINARY "wb" |
---|
48 | #define FOPEN_APPEND_BINARY "ab" |
---|
49 | #define FOPEN_WRITE_TEXT "wt" |
---|
50 | #define FOPEN_APPEND_TEXT "at" |
---|
51 | |
---|
52 | #ifdef LINUX |
---|
53 | #include <strings.h> |
---|
54 | #ifndef __CYGWIN__ |
---|
55 | #define stricmp(a,b) strcasecmp(a,b) |
---|
56 | #define strnicmp(a,b,c) strncasecmp(a,b,c) |
---|
57 | #endif |
---|
58 | #endif |
---|
59 | |
---|
60 | #if defined MACOS || defined __ANDROID__ || defined IPHONE |
---|
61 | #define stricmp(a,b) strcasecmp(a,b) |
---|
62 | #endif |
---|
63 | |
---|
64 | //typedef unsigned char boolean; //niestety nie mozna uzyc 'bool' bo VC w rpcndr.h wlasnie tak definiuje booleana, jako unsigned char |
---|
65 | //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. |
---|
66 | |
---|
67 | //vsnprintf implementations support different standards, some only return -1 instead of the required number of characters |
---|
68 | //these definitions are used by stl-util.cpp/ssprintf_va and SString::sprintf |
---|
69 | #ifdef LINUX |
---|
70 | #define VSNPRINTF_RETURNS_REQUIRED_SIZE |
---|
71 | #endif |
---|
72 | #if defined _WIN32 && !defined __BORLANDC__ |
---|
73 | #define USE_VSCPRINTF |
---|
74 | #endif |
---|
75 | |
---|
76 | |
---|
77 | #endif |
---|
78 | |
---|