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