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