Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

Conf.h

Go to the documentation of this file.
00001 // ZenLib::ZenTypes - To be independant of platform & compiler
00002 // Copyright (C) 2002-2003 Jérôme Martinez, Zen@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 // ZenTypes
00023 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00024 //
00025 // Independancies of types
00026 //               (u)int  (u)int  (u)int  (u)int  Float   Float
00027 //                8bit   16bit   32bit   64bit   32bit   64bit
00028 // Win32        :   X      X       X       X       X       X   
00029 // Unix         :   X      X       X
00030 //
00031 // Platform detection
00032 // WIN32, UNIX
00033 //
00034 // Easy Unicode Support
00035 // 
00036 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00037 //
00038 // 2005-07-10, Zen@MediaArea.net
00039 // MSVC8 adaptation
00040 //
00041 // 2005-03-03, Zen@MediaArea.net
00042 // MinGW linker bug workaround :(
00043 //
00044 // 2005-02-26, Zen@MediaArea.net
00045 // Delete tchar.h
00046 //
00047 // 2005-02-22, Zen@MediaArea.net
00048 // Some cleanup and platform-specific adaptation
00049 //
00050 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00051 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00052 
00053 //---------------------------------------------------------------------------
00054 #ifndef ZenTypesH
00055 #define ZenTypesH
00056 //---------------------------------------------------------------------------
00057 
00058 //***************************************************************************
00059 // Compiler bugs
00060 //***************************************************************************
00061 
00062 //MSVC6 : for(int t=0; t<10; ++t) { do something }; for(int t=0; t<10; ++t) { do something } 
00063 #if defined(_MSC_VER) && _MSC_VER <= 1200
00064     #define for if(true)for
00065     #pragma warning(disable:4786) // MSVC6 doesn't like typenames longer than 255 chars (which generates an enormous amount of warnings).
00066 #endif
00067 
00068 //MSVC8 : "deprecated" warning (replacement functions are not in MinGW or BCB!)
00069 #if defined(_MSC_VER) && _MSC_VER <= 1400
00070         #pragma warning(disable : 4996)
00071 #endif
00072 
00073 //(-1) is known to be the MAX of an unsigned integer but GCC complain about it
00074 namespace ZenLib
00075 {
00076     const unsigned int Error=((unsigned int)(-1));
00077 }
00078 //***************************************************************************
00079 // Includes
00080 //***************************************************************************
00081 
00082 //---------------------------------------------------------------------------
00083 #include <limits.h>
00084 #if defined(DEBUG) || defined(_DEBUG)
00085     #include <ZenLib/MemoryDebug.h>
00086 #endif // defined(DEBUG) || defined(_DEBUG)
00087 //---------------------------------------------------------------------------
00088 
00089 namespace ZenLib
00090 {
00091 
00092 //***************************************************************************
00093 // International
00094 //***************************************************************************
00095 
00096 //---------------------------------------------------------------------------
00097 //Unicode
00098 #if defined(_UNICODE) || defined(UNICODE) || defined(__UNICODE__)
00099     #ifndef _UNICODE
00100         #define _UNICODE
00101     #endif
00102     #ifndef UNICODE
00103         #define UNICODE
00104     #endif
00105     #ifndef __UNICODE__
00106         #define __UNICODE__
00107     #endif
00108 #endif
00109 
00110 //---------------------------------------------------------------------------
00111 //Char types
00112 #undef  _T
00113 #define _T(__x)     __T(__x)
00114 #undef  _TEXT
00115 #define _TEXT(__x)  __T(__x)
00116 #undef  __TEXT
00117 #define __TEXT(__x) __T(__x)
00118 #if defined(__UNICODE__)
00119     #if defined (_MSC_VER) && !defined (_NATIVE_WCHAR_T_DEFINED)
00120         #pragma message Native wchar_t is not defined, not tested, you should put /Zc:wchar_t in compiler options
00121     #endif
00122     typedef wchar_t Char;
00123     #undef  __T
00124     #define __T(__x) L##__x
00125 #else
00126     typedef char Char;
00127     #undef  __T
00128     #define __T(__x) __x
00129 #endif
00130 #ifdef wchar_t
00131         typedef wchar_t wchar;
00132 #endif
00133 
00134 //***************************************************************************
00135 // Platforms
00136 //***************************************************************************
00137 
00138 //---------------------------------------------------------------------------
00139 //Win32 (Win95, Win98, WinMe, WinNT, WinXP)
00140 #if defined(__NT__) || defined(_WIN32) || defined(WIN32)
00141     #ifndef WIN32
00142         #define WIN32
00143     #endif
00144     #ifndef _WIN32
00145         #define _WIN32
00146     #endif
00147     #ifndef __WIN32__
00148         #define __WIN32__ 1
00149     #endif
00150 #endif
00151 
00152 //---------------------------------------------------------------------------
00153 //Win64
00154 #if defined(_WIN64) || defined(WIN64)
00155     #ifndef WIN64
00156         #define WIN64
00157     #endif
00158     #ifndef _WIN64
00159         #define _WIN64
00160     #endif
00161     #ifndef __WIN64__
00162         #define __WIN64__ 1
00163     #endif
00164 #endif
00165 
00166 //---------------------------------------------------------------------------
00167 //Windows
00168 #if defined(WIN32) || defined(WIN64)
00169     #ifndef WINDOWS
00170         #define WINDOWS
00171     #endif
00172     #ifndef _WINDOWS
00173         #define _WINDOWS
00174     #endif
00175     #ifndef __WINDOWS__
00176         #define __WINDOWS__ 1
00177     #endif
00178 #endif
00179 
00180 
00181 //Unix (Linux, HP, Sun, BeOS...)
00182 #if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) \
00183     || defined(__unix) || defined(__unix__) \
00184     || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) \
00185     || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) \
00186     || defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
00187     #ifndef UNIX
00188         #define UNIX
00189     #endif
00190     #ifndef _UNIX
00191         #define _UNIX
00192     #endif
00193     #ifndef __UNIX__
00194         #define __UNIX__ 1
00195     #endif
00196 #endif
00197 
00198 //Test of targets
00199 #if defined(WIN32) && defined(UNIX)
00200     #pragma message Two platforms??? (WIN32 and UNIX is defined)
00201 #endif
00202 
00203 #if !defined(WIN32) && !defined(UNIX)
00204     #pragma message No known platforms, assume default
00205 #endif
00206 
00207 //***************************************************************************
00208 // Types
00209 //***************************************************************************
00210 
00211 //---------------------------------------------------------------------------
00212 //int
00213 typedef signed   int        ints;
00214 typedef unsigned int        intu;
00215 
00216 //---------------------------------------------------------------------------
00217 //8-bit int
00218 #if UCHAR_MAX==0xff
00219     #undef  MAXTYPE_INT
00220     #define MAXTYPE_INT 8
00221     typedef signed   char       int8s;
00222     typedef unsigned char       int8u;
00223 #else
00224     #pragma message This machine has no 8-bit integertype?
00225 #endif
00226 
00227 //---------------------------------------------------------------------------
00228 //16-bit int
00229 #if UINT_MAX == 0xffff
00230     #undef  MAXTYPE_INT
00231     #define MAXTYPE_INT 16
00232     typedef signed   int        int16s;
00233     typedef unsigned int        int16u;
00234 #elif USHRT_MAX == 0xffff
00235     #undef  MAXTYPE_INT
00236     #define MAXTYPE_INT 16
00237     typedef signed   short      int16s;
00238     typedef unsigned short      int16u;
00239 #else
00240     #pragma message This machine has no 16-bit integertype?
00241 #endif
00242 
00243 //---------------------------------------------------------------------------
00244 //32-bit int
00245 #if UINT_MAX == 0xfffffffful
00246     #undef  MAXTYPE_INT
00247     #define MAXTYPE_INT 32
00248     typedef signed   int        int32s;
00249     typedef unsigned int        int32u;
00250 #elif ULONG_MAX == 0xfffffffful
00251     #undef  MAXTYPE_INT
00252     #define MAXTYPE_INT 32
00253     typedef signed   long       int32s;
00254     typedef unsigned long       int32u;
00255 #elif USHRT_MAX == 0xfffffffful
00256     #undef  MAXTYPE_INT
00257     #define MAXTYPE_INT 32
00258     typedef signed   short      int32s;
00259     typedef unsigned short      int32u;
00260 #else
00261     #pragma message This machine has no 32-bit integer type?
00262 #endif
00263 
00264 //---------------------------------------------------------------------------
00265 //64-bit int
00266 #if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__)
00267     #undef  MAXTYPE_INT
00268     #define MAXTYPE_INT 64
00269     typedef signed   long long  int64s;
00270     typedef unsigned long long  int64u;
00271 #elif defined(__WIN32__)
00272     #undef  MAXTYPE_INT
00273     #define MAXTYPE_INT 64
00274     typedef signed   __int64    int64s;
00275     typedef unsigned __int64    int64u;
00276 #else
00277     #pragma message This machine has no 64-bit integer type?
00278 #endif
00279 
00280 //---------------------------------------------------------------------------
00281 //32-bit float
00282 #if defined(__WIN32__) || defined(__BORLANDC__) || defined(__UNIX__)
00283     #undef  MAXTYPE_FLOAT
00284     #define MAXTYPE_FLOAT 32
00285     typedef float                float32;
00286 #else
00287     #pragma message This machine has no 32-bit float type?
00288 #endif
00289 
00290 //---------------------------------------------------------------------------
00291 //64-bit float
00292 #if defined(__WIN32__) || defined(__BORLANDC__) || defined(__UNIX__)
00293     #undef  MAXTYPE_FLOAT
00294     #define MAXTYPE_FLOAT 64
00295     typedef double                float64;
00296 #else
00297     #pragma message This machine has no 64-bit float type?
00298 #endif
00299 
00300 //---------------------------------------------------------------------------
00301 //128-bit float
00302 #if defined(__WIN32__) || defined(__BORLANDC__) || defined(__UNIX__)
00303     #undef  MAXTYPE_FLOAT
00304     #define MAXTYPE_FLOAT 80
00305     typedef long double                float128; //Warning : only 80 bits
00306 #else
00307     #pragma message This machine has no 128-bit float type?
00308 #endif
00309 
00310 //***************************************************************************
00311 // Nested functions
00312 //***************************************************************************
00313 
00314 //Unices
00315 #if defined (UNIX)
00316     #define snwprintf swprintf
00317 #endif
00318 
00319 //Windows - MSVC
00320 #if defined (_MSC_VER)
00321     #define snprintf _snprintf
00322     #define snwprintf _snwprintf
00323 #endif
00324 
00325 } //namespace
00326 #endif
00327 

Generated on Sun Oct 16 20:41:19 2005 for ZenLib by doxygen1.3-rc3