1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
2 | // Copyright (C) 1999-2019 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 | |
---|
23 | /////////////////////////////////////////////////////// path separators and other macros |
---|
24 | #ifdef _WIN32 |
---|
25 | #define PATH_SEPARATOR_CHAR '\\' |
---|
26 | #define PATH_SEPARATOR_STRING "\\" |
---|
27 | #define FPU_THROWS_EXCEPTIONS |
---|
28 | #else |
---|
29 | #define PATH_SEPARATOR_CHAR '/' |
---|
30 | #define PATH_SEPARATOR_STRING "/" |
---|
31 | #endif |
---|
32 | |
---|
33 | #define FOPEN_READ_BINARY "rb" |
---|
34 | // no FOPEN_READ_TEXT |
---|
35 | #define FOPEN_WRITE_BINARY "wb" |
---|
36 | #define FOPEN_APPEND_BINARY "ab" |
---|
37 | #define FOPEN_WRITE_TEXT "wt" |
---|
38 | #define FOPEN_APPEND_TEXT "at" |
---|
39 | |
---|
40 | #ifdef LINUX |
---|
41 | #include <strings.h> |
---|
42 | #ifndef __CYGWIN__ |
---|
43 | #define stricmp(a,b) strcasecmp(a,b) |
---|
44 | #define strnicmp(a,b,c) strncasecmp(a,b,c) |
---|
45 | #endif |
---|
46 | #endif |
---|
47 | |
---|
48 | #if defined MACOS || defined __ANDROID__ || defined IPHONE |
---|
49 | #define stricmp(a,b) strcasecmp(a,b) |
---|
50 | #define strnicmp(a,b,c) strncasecmp(a,b,c) |
---|
51 | #endif |
---|
52 | |
---|
53 | |
---|
54 | //typedef unsigned char boolean; //niestety nie mozna uzyc 'bool' bo VC w rpcndr.h wlasnie tak definiuje booleana, jako unsigned char |
---|
55 | //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. |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | #ifdef __BORLANDC__ |
---|
60 | #define va_copy(to,from) ((to)=(from)) //borland's implementation of va_copy (the _Vacopy() function) copies from="" to to=NULL, and this behavior crashes our ssprintf_va(), so we prefer our simple macro since va_list is just a char* pointer in borland |
---|
61 | #endif |
---|
62 | |
---|
63 | |
---|
64 | //vsnprintf implementations support different standards, some only return -1 instead of the required number of characters |
---|
65 | //these definitions are used by stl-util.cpp/ssprintf_va and SString::sprintf |
---|
66 | #ifdef LINUX |
---|
67 | #define VSNPRINTF_RETURNS_REQUIRED_SIZE |
---|
68 | #endif |
---|
69 | #if defined _WIN32 && !defined __BORLANDC__ |
---|
70 | #define USE_VSCPRINTF |
---|
71 | #endif |
---|
72 | |
---|
73 | |
---|
74 | #endif |
---|