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