ZenLib

Conf.h

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