• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Conf.h

Go to the documentation of this file.
00001 // ZenLib::ZenTypes - To be independant of platform & compiler
00002 // Copyright (C) 2002-2010 MediaArea.net SARL, Info@MediaArea.net
00003 //
00004 // This software is provided 'as-is', without any express or implied
00005 // warranty.  In no event will the authors be held liable for any damages
00006 // arising from the use of this software.
00007 //
00008 // Permission is granted to anyone to use this software for any purpose,
00009 // including commercial applications, and to alter it and redistribute it
00010 // freely, subject to the following restrictions:
00011 //
00012 // 1. The origin of this software must not be misrepresented; you must not
00013 //    claim that you wrote the original software. If you use this software
00014 //    in a product, an acknowledgment in the product documentation would be
00015 //    appreciated but is not required.
00016 // 2. Altered source versions must be plainly marked as such, and must not be
00017 //    misrepresented as being the original software.
00018 // 3. This notice may not be removed or altered from any source distribution.
00019 //
00020 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00021 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00022 
00023 //---------------------------------------------------------------------------
00024 #ifndef ZenConfH
00025 #define ZenConfH
00026 //---------------------------------------------------------------------------
00027 
00028 //***************************************************************************
00029 // Platforms
00030 //***************************************************************************
00031 
00032 //---------------------------------------------------------------------------
00033 //Win32
00034 #if defined(__NT__) || defined(_WIN32) || defined(WIN32)
00035     #ifndef WIN32
00036         #define WIN32
00037     #endif
00038     #ifndef _WIN32
00039         #define _WIN32
00040     #endif
00041     #ifndef __WIN32__
00042         #define __WIN32__ 1
00043     #endif
00044 #endif
00045 
00046 //---------------------------------------------------------------------------
00047 //Win64
00048 #if defined(_WIN64) || defined(WIN64)
00049     #ifndef WIN64
00050         #define WIN64
00051     #endif
00052     #ifndef _WIN64
00053         #define _WIN64
00054     #endif
00055     #ifndef __WIN64__
00056         #define __WIN64__ 1
00057     #endif
00058 #endif
00059 
00060 //---------------------------------------------------------------------------
00061 //Windows
00062 #if defined(WIN32) || defined(WIN64)
00063     #ifndef WINDOWS
00064         #define WINDOWS
00065     #endif
00066     #ifndef _WINDOWS
00067         #define _WINDOWS
00068     #endif
00069     #ifndef __WINDOWS__
00070         #define __WINDOWS__ 1
00071     #endif
00072 #endif
00073 
00074 //---------------------------------------------------------------------------
00075 //Unix (Linux, HP, Sun, BeOS...)
00076 #if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) \
00077     || defined(__unix) || defined(__unix__) \
00078     || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) \
00079     || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) \
00080     || defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
00081     #ifndef UNIX
00082         #define UNIX
00083     #endif
00084     #ifndef _UNIX
00085         #define _UNIX
00086     #endif
00087     #ifndef __UNIX__
00088         #define __UNIX__ 1
00089     #endif
00090 #endif
00091 
00092 //---------------------------------------------------------------------------
00093 //MacOS Classic
00094 #if defined(macintosh)
00095     #ifndef MACOS
00096         #define MACOS
00097     #endif
00098     #ifndef _MACOS
00099         #define _MACOS
00100     #endif
00101     #ifndef __MACOS__
00102         #define __MACOS__ 1
00103     #endif
00104 #endif
00105 
00106 //---------------------------------------------------------------------------
00107 //MacOS X
00108 #if defined(__APPLE__) && defined(__MACH__)
00109     #ifndef MACOSX
00110         #define MACOSX
00111     #endif
00112     #ifndef _MACOSX
00113         #define _MACOSX
00114     #endif
00115     #ifndef __MACOSX__
00116         #define __MACOSX__ 1
00117     #endif
00118 #endif
00119 
00120 //Test of targets
00121 #if defined(WINDOWS) && defined(UNIX) && defined(MACOS) && defined(MACOSX)
00122     #pragma message Multiple platforms???
00123 #endif
00124 
00125 #if !defined(WIN32) && !defined(UNIX) && !defined(MACOS) && !defined(MACOSX)
00126     #pragma message No known platforms, assume default
00127 #endif
00128 
00129 //***************************************************************************
00130 // Internationnal
00131 //***************************************************************************
00132 
00133 //---------------------------------------------------------------------------
00134 //Unicode
00135 #if defined(_UNICODE) || defined(UNICODE) || defined(__UNICODE__)
00136     #ifndef _UNICODE
00137         #define _UNICODE
00138     #endif
00139     #ifndef UNICODE
00140         #define UNICODE
00141     #endif
00142     #ifndef __UNICODE__
00143         #define __UNICODE__ 1
00144     #endif
00145 #endif
00146 
00147 //---------------------------------------------------------------------------
00148 //wchar_t stuff
00149 #if defined(MACOS) || defined(MACOSX)
00150     #include <wchar.h>
00151 #endif
00152 
00153 //***************************************************************************
00154 // Compiler bugs/unuseful warning
00155 //***************************************************************************
00156 
00157 //MSVC6 : for(int t=0; t<10; ++t) { do something }; for(int t=0; t<10; ++t) { do something }
00158 #if defined(_MSC_VER) && _MSC_VER <= 1200
00159     #define for if(true)for
00160     #pragma warning(disable:4786) // MSVC6 doesn't like typenames longer than 255 chars (which generates an enormous amount of warnings).
00161 #endif
00162 
00163 //MSVC2005 : "deprecated" warning (replacement functions are not in MinGW32 or Borland!)
00164 #if defined(_MSC_VER) && _MSC_VER >= 1400
00165     #pragma warning(disable : 4996)
00166 #endif
00167 
00168 //***************************************************************************
00169 // (Without Namespace)
00170 //***************************************************************************
00171 
00172 //---------------------------------------------------------------------------
00173 #include <limits.h>
00174 
00175 //---------------------------------------------------------------------------
00176 #if defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG))
00177     #include "ZenLib/MemoryDebug.h"
00178 #endif // defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG))
00179 
00180 //***************************************************************************
00181 // Compiler helpers
00182 //***************************************************************************
00183 
00184 //---------------------------------------------------------------------------
00185 //Macro to cut down on compiler warnings
00186 #ifndef UNUSED
00187     #define UNUSED(Identifier)
00188 #endif
00189 //---------------------------------------------------------------------------
00190 //If we need size_t specific integer conversion
00191 #if defined(__LP64__) || defined(MACOSX)
00192     #define NEED_SIZET
00193 #endif
00194 
00195 //---------------------------------------------------------------------------
00196 //(-1) is known to be the MAX of an unsigned int but GCC complains about it
00197 #include <new>
00198 namespace ZenLib
00199 {
00200     const std::size_t Error=((std::size_t)(-1));
00201     const std::size_t All=((std::size_t)(-1));
00202     const std::size_t Unlimited=((std::size_t)(-1));
00203 }
00204 
00205 //***************************************************************************
00206 // (With namespace)
00207 //***************************************************************************
00208 
00209 namespace ZenLib
00210 {
00211 
00212 //***************************************************************************
00213 // International
00214 //***************************************************************************
00215 
00216 //---------------------------------------------------------------------------
00217 //Char types
00218 #undef  _T
00219 #define _T(__x)     __T(__x)
00220 #undef  _TEXT
00221 #define _TEXT(__x)  __T(__x)
00222 #undef  __TEXT
00223 #define __TEXT(__x) __T(__x)
00224 #if defined(__UNICODE__)
00225     #if defined (_MSC_VER) && !defined (_NATIVE_WCHAR_T_DEFINED)
00226         #pragma message Native wchar_t is not defined, not tested, you should put /Zc:wchar_t in compiler options
00227     #endif
00228     typedef wchar_t Char;
00229     #undef  __T
00230     #define __T(__x) L##__x
00231 #else // defined(__UNICODE__)
00232     typedef char Char;
00233     #undef  __T
00234     #define __T(__x) __x
00235 #endif // defined(__UNICODE__)
00236 #ifdef wchar_t
00237     typedef wchar_t wchar;
00238 #endif // wchar_t
00239 
00240 //***************************************************************************
00241 // Platform differences
00242 //***************************************************************************
00243 
00244 //End of line
00245 extern const Char* EOL;
00246 extern const Char  PathSeparator;
00247 
00248 //***************************************************************************
00249 // Types
00250 //***************************************************************************
00251 
00252 //---------------------------------------------------------------------------
00253 //int
00254 typedef signed   int            ints;
00255 typedef unsigned int            intu;
00256 
00257 //---------------------------------------------------------------------------
00258 //8-bit int
00259 #if UCHAR_MAX==0xff
00260     #undef  MAXTYPE_INT
00261     #define MAXTYPE_INT 8
00262     typedef signed   char       int8s;
00263     typedef unsigned char       int8u;
00264 #else
00265     #pragma message This machine has no 8-bit integertype?
00266 #endif
00267 
00268 //---------------------------------------------------------------------------
00269 //16-bit int
00270 #if UINT_MAX == 0xffff
00271     #undef  MAXTYPE_INT
00272     #define MAXTYPE_INT 16
00273     typedef signed   int        int16s;
00274     typedef unsigned int        int16u;
00275 #elif USHRT_MAX == 0xffff
00276     #undef  MAXTYPE_INT
00277     #define MAXTYPE_INT 16
00278     typedef signed   short      int16s;
00279     typedef unsigned short      int16u;
00280 #else
00281     #pragma message This machine has no 16-bit integertype?
00282 #endif
00283 
00284 //---------------------------------------------------------------------------
00285 //32-bit int
00286 #if UINT_MAX == 0xfffffffful
00287     #undef  MAXTYPE_INT
00288     #define MAXTYPE_INT 32
00289     typedef signed   int        int32s;
00290     typedef unsigned int        int32u;
00291 #elif ULONG_MAX == 0xfffffffful
00292     #undef  MAXTYPE_INT
00293     #define MAXTYPE_INT 32
00294     typedef signed   long       int32s;
00295     typedef unsigned long       int32u;
00296 #elif USHRT_MAX == 0xfffffffful
00297     #undef  MAXTYPE_INT
00298     #define MAXTYPE_INT 32
00299     typedef signed   short      int32s;
00300     typedef unsigned short      int32u;
00301 #else
00302     #pragma message This machine has no 32-bit integer type?
00303 #endif
00304 
00305 //---------------------------------------------------------------------------
00306 //64-bit int
00307 #if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__) || defined(__MACOSX__)
00308     #undef  MAXTYPE_INT
00309     #define MAXTYPE_INT 64
00310     typedef signed   long long  int64s;
00311     typedef unsigned long long  int64u;
00312 #elif defined(__WIN32__)
00313     #undef  MAXTYPE_INT
00314     #define MAXTYPE_INT 64
00315     typedef signed   __int64    int64s;
00316     typedef unsigned __int64    int64u;
00317 #else
00318     #pragma message This machine has no 64-bit integer type?
00319 #endif
00320 
00321 //---------------------------------------------------------------------------
00322 //32-bit float
00323 #if defined(WINDOWS) || defined(UNIX) || defined(MACOSX)
00324     #undef  MAXTYPE_FLOAT
00325     #define MAXTYPE_FLOAT 32
00326     typedef float                float32;
00327 #else
00328     #pragma message This machine has no 32-bit float type?
00329 #endif
00330 
00331 //---------------------------------------------------------------------------
00332 //64-bit float
00333 #if defined(WINDOWS) || defined(UNIX) || defined(MACOSX)
00334     #undef  MAXTYPE_FLOAT
00335     #define MAXTYPE_FLOAT 64
00336     typedef double                float64;
00337 #else
00338     #pragma message This machine has no 64-bit float type?
00339 #endif
00340 
00341 //---------------------------------------------------------------------------
00342 //80-bit float
00343 #if defined(WINDOWS) || defined(UNIX) || defined(MACOSX)
00344     #undef  MAXTYPE_FLOAT
00345     #define MAXTYPE_FLOAT 80
00346     typedef long double           float80;
00347 #else
00348     #pragma message This machine has no 80-bit float type?
00349 #endif
00350 
00351 //***************************************************************************
00352 // Nested functions
00353 //***************************************************************************
00354 
00355 //Unices
00356 #if defined (UNIX)
00357     #define snwprintf swprintf
00358 #endif
00359 
00360 //Windows - MSVC
00361 #if defined (_MSC_VER)
00362     #define snprintf _snprintf
00363     #define snwprintf _snwprintf
00364 #endif
00365 
00366 } //namespace
00367 #endif
00368 

Generated on Fri Dec 17 2010 14:21:08 for ZenLib by  doxygen 1.7.1