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-2006 Jerome 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       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 // MSVC2005 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 //MSVC2005 : "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 //BCB6 complain of some missing functions
00074 #if defined(__BORLANDC__)
00075     #include <sstream>
00076 #endif
00077 
00078 //(-1) is known to be the MAX of an unsigned integer but GCC complain about it
00079 namespace ZenLib
00080 {
00081     const unsigned int Error=((unsigned int)(-1));
00082     const unsigned int All=((unsigned int)(-1));
00083 }
00084 
00085 //***************************************************************************
00086 // Includes
00087 //***************************************************************************
00088 
00089 //---------------------------------------------------------------------------
00090 #include <limits.h>
00091 #if defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG))
00092         #include <ZenLib/MemoryDebug.h>
00093 #endif // defined(ZENLIB_DEBUG) && (defined(DEBUG) || defined(_DEBUG))
00094 //---------------------------------------------------------------------------
00095 
00096 namespace ZenLib
00097 {
00098 
00099 //***************************************************************************
00100 // International
00101 //***************************************************************************
00102 
00103 //---------------------------------------------------------------------------
00104 //Unicode
00105 #if defined(_UNICODE) || defined(UNICODE) || defined(__UNICODE__)
00106     #ifndef _UNICODE
00107         #define _UNICODE
00108     #endif
00109     #ifndef UNICODE
00110         #define UNICODE
00111     #endif
00112     #ifndef __UNICODE__
00113         #define __UNICODE__ 1
00114     #endif
00115 #endif
00116 
00117 //---------------------------------------------------------------------------
00118 //Char types
00119 #undef  _T
00120 #define _T(__x)     __T(__x)
00121 #undef  _TEXT
00122 #define _TEXT(__x)  __T(__x)
00123 #undef  __TEXT
00124 #define __TEXT(__x) __T(__x)
00125 #if defined(__UNICODE__)
00126     #if defined (_MSC_VER) && !defined (_NATIVE_WCHAR_T_DEFINED)
00127         #pragma message Native wchar_t is not defined, not tested, you should put /Zc:wchar_t in compiler options
00128     #endif
00129     typedef wchar_t Char;
00130     #undef  __T
00131     #define __T(__x) L##__x
00132 #else // defined(__UNICODE__)
00133     typedef char Char;
00134     #undef  __T
00135     #define __T(__x) __x
00136 #endif // defined(__UNICODE__)
00137 #ifdef wchar_t
00138     typedef wchar_t wchar;
00139 #endif // wchar_t
00140 
00141 //***************************************************************************
00142 // Platforms
00143 //***************************************************************************
00144 
00145 //---------------------------------------------------------------------------
00146 //Win32
00147 #if defined(__NT__) || defined(_WIN32) || defined(WIN32)
00148     #ifndef WIN32
00149         #define WIN32
00150     #endif
00151     #ifndef _WIN32
00152         #define _WIN32
00153     #endif
00154     #ifndef __WIN32__
00155         #define __WIN32__ 1
00156     #endif
00157 #endif
00158 
00159 //---------------------------------------------------------------------------
00160 //Win64
00161 #if defined(_WIN64) || defined(WIN64)
00162     #ifndef WIN64
00163         #define WIN64
00164     #endif
00165     #ifndef _WIN64
00166         #define _WIN64
00167     #endif
00168     #ifndef __WIN64__
00169         #define __WIN64__ 1
00170     #endif
00171 #endif
00172 
00173 //---------------------------------------------------------------------------
00174 //Windows
00175 #if defined(WIN32) || defined(WIN64)
00176     #ifndef WINDOWS
00177         #define WINDOWS
00178     #endif
00179     #ifndef _WINDOWS
00180         #define _WINDOWS
00181     #endif
00182     #ifndef __WINDOWS__
00183         #define __WINDOWS__ 1
00184     #endif
00185 #endif
00186 
00187 //---------------------------------------------------------------------------
00188 //Unix (Linux, HP, Sun, BeOS...)
00189 #if defined(UNIX) || defined(_UNIX) || defined(__UNIX__) \
00190     || defined(__unix) || defined(__unix__) \
00191     || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) \
00192     || defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) \
00193     || defined(__EMX__) || defined(__VMS) || defined(__BEOS__)
00194     #ifndef UNIX
00195         #define UNIX
00196     #endif
00197     #ifndef _UNIX
00198         #define _UNIX
00199     #endif
00200     #ifndef __UNIX__
00201         #define __UNIX__ 1
00202     #endif
00203 #endif
00204 
00205 //Test of targets
00206 #if defined(WIN32) && defined(UNIX)
00207     #pragma message Two platforms??? (WIN32 and UNIX is defined)
00208 #endif
00209 
00210 #if !defined(WIN32) && !defined(UNIX)
00211     #pragma message No known platforms, assume default
00212 #endif
00213 
00214 //***************************************************************************
00215 // Types
00216 //***************************************************************************
00217 
00218 //---------------------------------------------------------------------------
00219 //int
00220 typedef signed   int            ints;
00221 typedef unsigned int            intu;
00222 
00223 //---------------------------------------------------------------------------
00224 //8-bit int
00225 #if UCHAR_MAX==0xff
00226     #undef  MAXTYPE_INT
00227     #define MAXTYPE_INT 8
00228     typedef signed   char       int8s;
00229     typedef unsigned char       int8u;
00230 #else
00231     #pragma message This machine has no 8-bit integertype?
00232 #endif
00233 
00234 //---------------------------------------------------------------------------
00235 //16-bit int
00236 #if UINT_MAX == 0xffff
00237     #undef  MAXTYPE_INT
00238     #define MAXTYPE_INT 16
00239     typedef signed   int        int16s;
00240     typedef unsigned int        int16u;
00241 #elif USHRT_MAX == 0xffff
00242     #undef  MAXTYPE_INT
00243     #define MAXTYPE_INT 16
00244     typedef signed   short      int16s;
00245     typedef unsigned short      int16u;
00246 #else
00247     #pragma message This machine has no 16-bit integertype?
00248 #endif
00249 
00250 //---------------------------------------------------------------------------
00251 //32-bit int
00252 #if UINT_MAX == 0xfffffffful
00253     #undef  MAXTYPE_INT
00254     #define MAXTYPE_INT 32
00255     typedef signed   int        int32s;
00256     typedef unsigned int        int32u;
00257 #elif ULONG_MAX == 0xfffffffful
00258     #undef  MAXTYPE_INT
00259     #define MAXTYPE_INT 32
00260     typedef signed   long       int32s;
00261     typedef unsigned long       int32u;
00262 #elif USHRT_MAX == 0xfffffffful
00263     #undef  MAXTYPE_INT
00264     #define MAXTYPE_INT 32
00265     typedef signed   short      int32s;
00266     typedef unsigned short      int32u;
00267 #else
00268     #pragma message This machine has no 32-bit integer type?
00269 #endif
00270 
00271 //---------------------------------------------------------------------------
00272 //64-bit int
00273 #if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__UNIX__)
00274     #undef  MAXTYPE_INT
00275     #define MAXTYPE_INT 64
00276     typedef signed   long long  int64s;
00277     typedef unsigned long long  int64u;
00278 #elif defined(__WIN32__)
00279     #undef  MAXTYPE_INT
00280     #define MAXTYPE_INT 64
00281     typedef signed   __int64    int64s;
00282     typedef unsigned __int64    int64u;
00283 #else
00284     #pragma message This machine has no 64-bit integer type?
00285 #endif
00286 
00287 //---------------------------------------------------------------------------
00288 //32-bit float
00289 #if defined(__WIN32__) || defined(__BORLANDC__) || defined(__UNIX__)
00290     #undef  MAXTYPE_FLOAT
00291     #define MAXTYPE_FLOAT 32
00292     typedef float                float32;
00293 #else
00294     #pragma message This machine has no 32-bit float type?
00295 #endif
00296 
00297 //---------------------------------------------------------------------------
00298 //64-bit float
00299 #if defined(__WIN32__) || defined(__BORLANDC__) || defined(__UNIX__)
00300     #undef  MAXTYPE_FLOAT
00301     #define MAXTYPE_FLOAT 64
00302     typedef double                float64;
00303 #else
00304     #pragma message This machine has no 64-bit float type?
00305 #endif
00306 
00307 //---------------------------------------------------------------------------
00308 //128-bit float
00309 #if defined(__WIN32__) || defined(__BORLANDC__) || defined(__UNIX__)
00310     #undef  MAXTYPE_FLOAT
00311     #define MAXTYPE_FLOAT 80
00312     typedef long double                float128; //Warning : only 80 bits
00313 #else
00314     #pragma message This machine has no 128-bit float type?
00315 #endif
00316 
00317 //***************************************************************************
00318 // Nested functions
00319 //***************************************************************************
00320 
00321 //Unices
00322 #if defined (UNIX)
00323     #define snwprintf swprintf
00324 #endif
00325 
00326 //Windows - MSVC
00327 #if defined (_MSC_VER)
00328     #define snprintf _snprintf
00329     #define snwprintf _snwprintf
00330 #endif
00331 
00332 } //namespace
00333 #endif
00334 

Generated on Mon Jul 24 09:22:57 2006 for ZenLib by doxygen1.3-rc3