ZenLib
Conf.h
Go to the documentation of this file.
1 /* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2  *
3  * Use of this source code is governed by a zlib-style license that can
4  * be found in the License.txt file in the root of the source tree.
5  */
6 
7 //---------------------------------------------------------------------------
8 #ifndef ZenConfH
9 #define ZenConfH
10 //---------------------------------------------------------------------------
11 
12 //***************************************************************************
13 // Platforms
14 //***************************************************************************
15 
16 //---------------------------------------------------------------------------
17 //Win32
18 #if defined(__NT__) || defined(_WIN32) || defined(WIN32)
19  #ifndef WIN32
20  #define WIN32
21  #endif
22  #ifndef _WIN32
23  #define _WIN32
24  #endif
25  #ifndef __WIN32__
26  #define __WIN32__ 1
27  #endif
28 #endif
29 
30 //---------------------------------------------------------------------------
31 //Win64
32 #if defined(_WIN64) || defined(WIN64)
33  #ifndef WIN64
34  #define WIN64
35  #endif
36  #ifndef _WIN64
37  #define _WIN64
38  #endif
39  #ifndef __WIN64__
40  #define __WIN64__ 1
41  #endif
42 #endif
43 
44 //---------------------------------------------------------------------------
45 //Windows
46 #if defined(WIN32) || defined(WIN64)
47  #ifndef WINDOWS
48  #define WINDOWS
49  #endif
50  #ifndef _WINDOWS
51  #define _WINDOWS
52  #endif
53  #ifndef __WINDOWS__
54  #define __WINDOWS__ 1
55  #endif
56 #endif
57 
58 //---------------------------------------------------------------------------
59 //Windows UWP
60 #if defined(WIN32) || defined(WIN64)
61  #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP)
62  #ifndef WINDOWS_UWP
63  #define WINDOWS_UWP
64  #endif
65  #endif
66  #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_GAMES)
67  #ifndef WINDOWS_GAMES
68  #define WINDOWS_GAMES
69  #endif
70  #endif
71 #endif
72 
73 //---------------------------------------------------------------------------
74 //Unix (Linux, HP, Sun, BeOS...)
75 #if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) \
76  || defined(__unix) || defined(__unix__) \
77  || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) \
78  || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) \
79  || defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
80  #ifndef UNIX
81  #define UNIX
82  #endif
83  #ifndef _UNIX
84  #define _UNIX
85  #endif
86  #ifndef __UNIX__
87  #define __UNIX__ 1
88  #endif
89 #endif
90 
91 //---------------------------------------------------------------------------
92 //MacOS Classic
93 #if defined(macintosh)
94  #ifndef MACOS
95  #define MACOS
96  #endif
97  #ifndef _MACOS
98  #define _MACOS
99  #endif
100  #ifndef __MACOS__
101  #define __MACOS__ 1
102  #endif
103 #endif
104 
105 //---------------------------------------------------------------------------
106 //MacOS X
107 #if defined(__APPLE__) && defined(__MACH__)
108  #ifndef MACOSX
109  #define MACOSX
110  #endif
111  #ifndef _MACOSX
112  #define _MACOSX
113  #endif
114  #ifndef __MACOSX__
115  #define __MACOSX__ 1
116  #endif
117 #endif
118 
119 //Test of targets
120 #if defined(WINDOWS) && defined(UNIX) && defined(MACOS) && defined(MACOSX)
121  #pragma message Multiple platforms???
122 #endif
123 
124 #if !defined(WIN32) && !defined(UNIX) && !defined(MACOS) && !defined(MACOSX)
125  #pragma message No known platforms, assume default
126 #endif
127 
128 //***************************************************************************
129 // Internationnal
130 //***************************************************************************
131 
132 //---------------------------------------------------------------------------
133 //Unicode
134 #if defined(_UNICODE) || defined(UNICODE) || defined(__UNICODE__)
135  #ifndef _UNICODE
136  #define _UNICODE
137  #endif
138  #ifndef UNICODE
139  #define UNICODE
140  #endif
141  #ifndef __UNICODE__
142  #define __UNICODE__ 1
143  #endif
144 #endif
145 
146 //---------------------------------------------------------------------------
147 //wchar_t stuff
148 #if defined(MACOS) || defined(MACOSX)
149  #include <wchar.h>
150 #endif
151 
152 //***************************************************************************
153 // Compiler bugs/unuseful warning
154 //***************************************************************************
155 
156 //MSVC6 : for(int t=0; t<10; ++t) { do something }; for(int t=0; t<10; ++t) { do something }
157 #if defined(_MSC_VER) && _MSC_VER <= 1200
158  #define for if(true)for
159  #pragma warning(disable:4786) // MSVC6 doesn't like typenames longer than 255 chars (which generates an enormous amount of warnings).
160 #endif
161 
162 //MSVC2005 : "deprecated" warning (replacement functions are not in MinGW32 or Borland!)
163 #if defined(_MSC_VER) && _MSC_VER >= 1400
164  #pragma warning(disable : 4996)
165 #endif
166 
167 //***************************************************************************
168 // (Without Namespace)
169 //***************************************************************************
170 
171 //---------------------------------------------------------------------------
172 #include <limits.h>
173 
174 //---------------------------------------------------------------------------
175 #if defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG))
176  #include "ZenLib/MemoryDebug.h"
177 #endif // defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG))
178 
179 //***************************************************************************
180 // Compiler helpers
181 //***************************************************************************
182 
183 //---------------------------------------------------------------------------
184 //Macro to cut down on compiler warnings
185 #ifndef UNUSED
186  #define UNUSED(Identifier)
187 #endif
188 //---------------------------------------------------------------------------
189 //If we need size_t specific integer conversion
190 #if !defined(SIZE_T_IS_LONG) && (defined(__LP64__) || defined(MACOSX))
191  #define SIZE_T_IS_LONG
192 #endif
193 
194 //---------------------------------------------------------------------------
195 //(-1) is known to be the MAX of an unsigned int but GCC complains about it
196 #ifdef __cplusplus
197  #include <new> //for size_t
198 #else /* __cplusplus */
199  #include <stddef.h> //for size_t
200 #endif /* __cplusplus */
201 #include <cstring> //size_t
202 namespace ZenLib
203 {
204  const std::size_t Error=((std::size_t)(-1));
205  const std::size_t All=((std::size_t)(-1));
206  const std::size_t Unlimited=((std::size_t)(-1));
207 }
208 
209 //***************************************************************************
210 // (With namespace)
211 //***************************************************************************
212 
213 namespace ZenLib
214 {
215 
216 //***************************************************************************
217 // International
218 //***************************************************************************
219 
220 //---------------------------------------------------------------------------
221 //Char types
222 #if defined(__UNICODE__)
223  #if defined (_MSC_VER) && !defined (_NATIVE_WCHAR_T_DEFINED)
224  #pragma message Native wchar_t is not defined, not tested, you should put /Zc:wchar_t in compiler options
225  #endif
226  typedef wchar_t Char;
227  #undef __T
228  #define __T(__x) L ## __x
229 #else // defined(__UNICODE__)
230  typedef char Char;
231  #undef __T
232  #define __T(__x) __x
233 #endif // defined(__UNICODE__)
234 #ifdef wchar_t
235  typedef wchar_t wchar;
236 #endif // wchar_t
237 
238 //***************************************************************************
239 // Platform differences
240 //***************************************************************************
241 
242 //End of line
243 extern const Char* EOL;
244 extern const Char PathSeparator;
245 
246 //***************************************************************************
247 // Types
248 //***************************************************************************
249 
250 //---------------------------------------------------------------------------
251 //int
252 typedef signed int ints;
253 typedef unsigned int intu;
254 
255 //---------------------------------------------------------------------------
256 //8-bit int
257 #if UCHAR_MAX==0xff
258  #undef MAXTYPE_INT
259  #define MAXTYPE_INT 8
260  typedef signed char int8s;
261  typedef unsigned char int8u;
262 #else
263  #pragma message This machine has no 8-bit integertype?
264 #endif
265 
266 //---------------------------------------------------------------------------
267 //16-bit int
268 #if UINT_MAX == 0xffff
269  #undef MAXTYPE_INT
270  #define MAXTYPE_INT 16
271  typedef signed int int16s;
272  typedef unsigned int int16u;
273 #elif USHRT_MAX == 0xffff
274  #undef MAXTYPE_INT
275  #define MAXTYPE_INT 16
276  typedef signed short int16s;
277  typedef unsigned short int16u;
278 #else
279  #pragma message This machine has no 16-bit integertype?
280 #endif
281 
282 //---------------------------------------------------------------------------
283 //32-bit int
284 #if UINT_MAX == 0xfffffffful
285  #undef MAXTYPE_INT
286  #define MAXTYPE_INT 32
287  typedef signed int int32s;
288  typedef unsigned int int32u;
289 #elif ULONG_MAX == 0xfffffffful
290  #undef MAXTYPE_INT
291  #define MAXTYPE_INT 32
292  typedef signed long int32s;
293  typedef unsigned long int32u;
294 #elif USHRT_MAX == 0xfffffffful
295  #undef MAXTYPE_INT
296  #define MAXTYPE_INT 32
297  typedef signed short int32s;
298  typedef unsigned short int32u;
299 #else
300  #pragma message This machine has no 32-bit integer type?
301 #endif
302 
303 //---------------------------------------------------------------------------
304 //64-bit int
305 #if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__)
306  #undef MAXTYPE_INT
307  #define MAXTYPE_INT 64
308  typedef signed long long int64s;
309  typedef unsigned long long int64u;
310 #elif defined(__WIN32__)
311  #undef MAXTYPE_INT
312  #define MAXTYPE_INT 64
313  typedef signed __int64 int64s;
314  typedef unsigned __int64 int64u;
315 #else
316  #pragma message This machine has no 64-bit integer type?
317 #endif
318 
319 //---------------------------------------------------------------------------
320 //32-bit float
321 #if defined(WINDOWS) || defined(UNIX) || defined(MACOSX)
322  #undef MAXTYPE_FLOAT
323  #define MAXTYPE_FLOAT 32
324  typedef float float32;
325 #else
326  #pragma message This machine has no 32-bit float type?
327 #endif
328 
329 //---------------------------------------------------------------------------
330 //64-bit float
331 #if defined(WINDOWS) || defined(UNIX) || defined(MACOSX)
332  #undef MAXTYPE_FLOAT
333  #define MAXTYPE_FLOAT 64
334  typedef double float64;
335 #else
336  #pragma message This machine has no 64-bit float type?
337 #endif
338 
339 //---------------------------------------------------------------------------
340 //80-bit float
341 #if defined(WINDOWS) || defined(UNIX) || defined(MACOSX)
342  #undef MAXTYPE_FLOAT
343  #define MAXTYPE_FLOAT 80
344  typedef long double float80;
345 #else
346  #pragma message This machine has no 80-bit float type?
347 #endif
348 
349 //***************************************************************************
350 // Nested functions
351 //***************************************************************************
352 
353 //Unices
354 #if defined (UNIX)
355  #define snwprintf swprintf
356 #endif
357 
358 //Windows - MSVC (before Visual Studio 2015)
359 #if defined (_MSC_VER) && _MSC_VER < 1900
360  #define snprintf _snprintf
361  #define snwprintf _snwprintf
362 #endif
363 
364 } //namespace
365 #endif
const Char PathSeparator
char Char
Definition: Conf.h:230
const std::size_t Error
Definition: Conf.h:204
const Char * EOL
signed int ints
Definition: Conf.h:252
unsigned int intu
Definition: Conf.h:253
const std::size_t All
Definition: Conf.h:205
const std::size_t Unlimited
Definition: Conf.h:206