source: cpp/common/nonstd.h @ 842

Last change on this file since 842 was 842, checked in by Maciej Komosinski, 22 months ago

Simple va_copy still needed for C++Builder

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
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
23/////////////////////////////////////////////////////// 64-bit int type and other macros
24#ifdef _WIN32
25        typedef __int64 LONGLONG;
26        #define PATH_SEPARATOR_CHAR '\\'
27        #define PATH_SEPARATOR_STRING "\\"
28        #define FPU_THROWS_EXCEPTIONS
29#else
30        #define LONGLONG long long int
31        #define PATH_SEPARATOR_CHAR '/'
32        #define PATH_SEPARATOR_STRING "/"
33#endif
34
35#define FOPEN_READ_BINARY "rb"
36// no FOPEN_READ_TEXT
37#define FOPEN_WRITE_BINARY "wb"
38#define FOPEN_APPEND_BINARY "ab"
39#define FOPEN_WRITE_TEXT "wt"
40#define FOPEN_APPEND_TEXT "at"
41
42#ifdef LINUX
43 #include <strings.h>
44 #ifndef __CYGWIN__
45  #define stricmp(a,b) strcasecmp(a,b)
46  #define strnicmp(a,b,c) strncasecmp(a,b,c)
47#endif
48#endif
49
50#if defined MACOS || defined __ANDROID__ || defined IPHONE
51 #define stricmp(a,b) strcasecmp(a,b)
52 #define strnicmp(a,b,c) strncasecmp(a,b,c)
53#endif
54
55
56//typedef unsigned char boolean; //niestety nie mozna uzyc 'bool' bo VC w rpcndr.h wlasnie tak definiuje booleana, jako unsigned char
57//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.
58
59
60
61#ifdef __BORLANDC__
62 #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
63#endif
64
65
66//vsnprintf implementations support different standards, some only return -1 instead of the required number of characters
67//these definitions are used by stl-util.cpp/ssprintf_va and SString::sprintf
68#ifdef LINUX
69#define VSNPRINTF_RETURNS_REQUIRED_SIZE
70#endif
71#if defined _WIN32 && !defined __BORLANDC__
72#define USE_VSCPRINTF
73#endif
74
75
76#endif
77
Note: See TracBrowser for help on using the repository browser.