opennurbs_system.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00017 /*
00019 //
00020 //   Includes all system headers required to use the openNURBS toolkit.
00021 //
00023 */
00024 
00025 #if !defined(OPENNURBS_SYSTEM_INC_)
00026 #define OPENNURBS_SYSTEM_INC_
00027 
00028 // The public release of opennurbs as a source code C++
00029 // library is built with OPENNURBS_PUBLIC_RELEASE
00030 // defined.
00031 #define OPENNURBS_PUBLIC_RELEASE
00032 
00033 /* compiler choice */
00034 #if defined(_MSC_VER)
00035 
00036 #if defined(OPENNURBS_EXPORTS)
00037 // "OPENNURBS_EXPORTS" is Microsoft's prefered define to indicate
00038 // an opennurbs DLL is being compiled.
00039 #if !defined(ON_DLL_EXPORTS)
00040 #define ON_DLL_EXPORTS
00041 #endif
00042 #if !defined(ON_COMPILING_OPENNURBS)
00043 #define ON_COMPILING_OPENNURBS
00044 #endif
00045 #endif
00046 
00047 #if defined(OPENNURBS_IMPORTS)
00048 // "OPENNURBS_IMPORTS" is Microsoft's prefered define to indicate
00049 // an opennurbs DLL is being linked with.
00050 #if !defined(ON_DLL_IMPORTS)
00051 #define ON_DLL_IMPORTS
00052 #endif
00053 #endif
00054 
00055 /* using a Microsoft compiler */
00056 #define ON_COMPILER_MSC
00057 
00058 #if _MSC_VER >= 1300
00059 #define ON_COMPILER_MSC1300
00060 // If you are using VC7/.NET and are having trouble linking 
00061 // to functions that have whcar_t types in arguments, then
00062 // read the documentation about the wchar_t type and
00063 // the /Zc:wchar_t compiler option.
00064 
00065 #if _MSC_VER >= 1400
00066 // Using at least Visual C++ 8.0 (2005)
00067 #define ON_COMPILER_MSC1400
00068 
00069 
00070 #if _MSC_VER >= 1600
00071 // Using at least Visual C++ 10.0 (2010)
00072 #define ON_COMPILER_MSC1600
00073 #endif
00074 
00075 // We are using /W4 wrning levels and disable
00076 // these warnings.  I would prefer to use
00077 // /W3 and enable the level 4 warnings we want,
00078 // but microsoft does not have a way to use pragmas
00079 // to enable specific warnings.
00080 
00081 #if defined(ON_COMPILING_OPENNURBS)
00082 #pragma warning(disable:4100) // C4100: 'identifier' : unreferenced formal parameter
00083 #endif
00084 
00085 #if !defined(_CRT_SECURE_NO_DEPRECATE)
00086 #define _CRT_SECURE_NO_DEPRECATE
00087 // Visual Studio 2005 issues a C4996 warning for lots of
00088 // standard C runtime functions that take string pointers.
00089 // The _CRT_SECURE_NO_DEPRECATE suppresses these warnings.
00090 // If you are an IT manager type and really care about these
00091 // sorts of things, then comment out the define.
00092 #endif
00093 
00094 #endif
00095 
00096 #endif
00097 
00098 #endif
00099 
00100 #if defined(__GNUG_) || defined(__GNUG__) || defined(__GNUC_) || defined(__GNUC__) || defined(_GNU_SOURCE) || defined(__GNU_SOURCE)
00101 /* using Gnu's compiler */
00102 #if !defined(ON_COMPILER_GNU)
00103 #define ON_COMPILER_GNU
00104 #endif
00105 #if !defined(_GNU_SOURCE)
00106 #define _GNU_SOURCE
00107 #endif
00108 #endif
00109 
00110 
00111 #if defined(_GNU_SOURCE) && defined(__APPLE__)
00112 /* using Apple's OSX XCode compiler */
00113 #if !defined(ON_COMPILER_XCODE)
00114 #define ON_COMPILER_XCODE
00115 #endif
00116 #endif
00117 
00118 #if defined(__BORLANDC__)
00119 /* using Borland's compiler */
00120 #define ON_COMPILER_BORLAND
00121 #endif
00122 
00123 /*
00124 // Define ON_NO_WINDOWS if you are compiling on a Windows system but want
00125 // to explicitly exclude inclusion of windows.h.
00126 */
00127 
00128 #if !defined(ON_NO_WINDOWS)
00129 
00130 /*
00132 //
00133 // Begin Windows system includes - 
00134 */
00135 #if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64)
00136 
00137 #if defined(_M_X64) && defined(WIN32) && defined(WIN64)
00138 // 23 August 2007 Dale Lear
00139 
00140 #if defined(_INC_WINDOWS)
00141 // The user has included Microsoft's windows.h before opennurbs.h,
00142 // and windows.h has nested includes that unconditionally define WIN32.
00143 // Just undo the damage here or everybody that includes opennurbs.h after
00144 // windows.h has to fight with this Microsoft bug.
00145 #undef WIN32
00146 #else
00147 #error do not define WIN32 for x64 builds
00148 #endif
00149 
00150 // NOTE _WIN32 is defined for any type of Windows build
00151 #endif
00152 
00153 /*
00154 // From windows.h openNURBS only needs definitions of ON_BOOL32, true,
00155 // and false, and a declarations of OutputDebugString(), and
00156 // WideCharToMultiByte().  These 
00157 // defines disable the inclusion of most of the Windows garbage.
00158 */
00159 
00160 #if defined(ON_COMPILER_MSC1600)
00161 // include SKDDDKVer.h When using the v100 platform headers.
00162 // Including SDKDDKVer.h defines the highest available Windows platform.
00163 // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
00164 // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
00165 //#include <SDKDDKVer.h>
00166 #endif
00167 
00168 #if !defined(_WINDOWS_)
00169 /* windows.h has not been read - read just what we need */
00170 #define WIN32_LEAN_AND_MEAN  /* Exclude rarely-used stuff from Windows headers */
00171 #include <windows.h>
00172 #endif
00173 
00174 #if defined(_M_X64) && defined(WIN32) && defined(WIN64)
00175 // 23 August 2007 Dale Lear
00176 //   windows.h unconditionally defines WIN32  This is a bug
00177 //   and the hope is this simple undef will let us continue.
00178 #undef WIN32
00179 #endif
00180 
00181 /*
00182 // if ON_OS_WINDOWS is defined, debugging and error
00183 // handing uses some Windows calls and ON_String
00184 // includes resource support.
00185 */
00186 
00187 #if !defined(ON_OS_WINDOWS)
00188 #define ON_OS_WINDOWS
00189 #endif
00190 
00191 #if defined(ON_OS_WINDOWS) && !defined(NOGDI)
00192 // ok to use Windows GDI RECT, LOGFONT, ... stucts.
00193 #define ON_OS_WINDOWS_GDI
00194 #endif
00195 
00196 #if defined(_MSC_VER)
00197 /* 
00198   Microsoft's Visual C/C++ requires some functions, including those that
00199   use vargs to be declared with __cdecl 
00200   Since this code must also compile with non-Micorosoft compilers, 
00201   the ON_MSC_CDECL macro is used to insert __cdecl when needed.
00202 */
00203 #define ON_MSC_CDECL __cdecl
00204 
00205 #endif
00206 
00207 #endif
00208 
00209 #endif
00210 
00211 // NOTE: Do not use rand_s() - it crashes Win2000.
00212 //
00213 //#if defined(_MSC_VER) && !defined(_CRT_RAND_S)
00217 //#define _CRT_RAND_S
00218 //#endif
00219 
00220 #include <stdlib.h>
00221 #include <memory.h>
00222 #if defined(ON_COMPILER_XCODE)
00223 #include <malloc/malloc.h>
00224 #else
00225 #include <malloc.h>
00226 #endif
00227 #include <string.h>
00228 #include <math.h>
00229 #include <stdio.h>
00230 #include <stdarg.h>
00231 #include <float.h>
00232 #include <time.h>
00233 #include <limits.h>
00234 #include <ctype.h>
00235 
00236 #if defined(ON_COMPILER_IRIX)
00237 #include <alloca.h>
00238 #endif
00239 
00240 #if !defined(ON_COMPILER_BORLAND)
00241 #include <wchar.h>
00242 #endif
00243 
00244 #if defined(ON_OS_WINDOWS)
00245 #include <io.h>
00246 #include <sys/stat.h>
00247 #include <tchar.h>
00248 
00249 // ON_CreateUuid calls Windows's ::UuidCreate() which
00250 // is declared in Rpcdce.h and defined in Rpcrt4.lib.
00251 #include <Rpc.h>
00252 
00253 #endif
00254 
00255 #if defined(ON_COMPILER_GNU)
00256 #include <sys/types.h>
00257 #include <sys/stat.h>
00258 #include <wctype.h>
00259 #include <dirent.h>
00260 #if defined(ON_COMPILER_XCODE)
00261 #include <uuid/uuid.h>
00262 #endif
00263 #endif
00264 
00265 #include <errno.h>
00266 
00267 #if defined (cplusplus) || defined(_cplusplus) || defined(__cplusplus)
00268 // C++ system includes
00269 
00270 #if !defined(ON_CPLUSPLUS)
00271 #define ON_CPLUSPLUS
00272 #endif
00273 
00274 #include <new> // for declaration of placement versions of new used in onClassArray<>.
00275 
00276 #endif
00277 
00278 #if !defined(ON_MSC_CDECL)
00279 #define ON_MSC_CDECL
00280 #endif
00281 
00282 #if !defined(ON_OS_WINDOWS) && !defined(_GNU_SOURCE) && !defined(ON_COMPILER_XCODE)
00283 
00284 /* define wchar_t, true, false, NULL */
00285 
00286 #if !defined(true)
00287 #define true true
00288 #endif
00289 
00290 #if !defined(false)
00291 #define false false
00292 #endif
00293 
00294 #if !defined(NULL)
00295 #define NULL 0
00296 #endif
00297 
00298 #if !defined(_WCHAR_T_DEFINED)
00299 // If you are using VC7/.NET and are having trouble linking 
00300 // to functions that have whcar_t types in arguments, then
00301 // read the documentation about the wchar_t type and
00302 // the /Zc:wchar_t compiler option.  Since 
00303 
00304 /* 16-bit wide character ("UNICODE") */
00305 
00306 #if !defined(_WCHAR_T)
00307 typedef unsigned short wchar_t;
00308 #endif
00309 
00310 #define _WCHAR_T_DEFINED
00311 #endif
00312 
00313 #endif
00314 
00315 
00316 // As 64 bit compilers become more common, the definitions
00317 // of the next 6 typedefs may need to vary with compiler.
00318 // As much as possible, the size of runtime types is left 
00319 // up to the compiler so performance and ease of use can 
00320 // be maximized.  In the rare cases where it is critical 
00321 // to use an integer that is exactly 16 bits, 32 bits 
00322 // or 64 bits, the ON__INT16, ON__INT32, and ON__INT64
00323 // typedefs are used.
00324 
00325 #if defined(_M_X64) || defined(_WIN64) || defined(__LP64__)
00326 // 64 bit (8 byte) pointers
00327 #define ON_SIZEOF_POINTER 8
00328 #define ON_64BIT_POINTER
00329 // ON_MAX_SIZET = maximum value of a size_t type
00330 #define ON_MAX_SIZE_T 0xFFFFFFFFFFFFFFFF
00331 #else
00332 // 32 bit (4 byte) pointers
00333 #define ON_SIZEOF_POINTER 4
00334 #define ON_32BIT_POINTER
00335 // ON_MAX_SIZET = maximum value of a size_t type
00336 #define ON_MAX_SIZE_T 0xFFFFFFFF
00337 #endif
00338 
00339 // 8 bit integer
00340 typedef char ON__INT8;
00341 
00342 // 8 bit unsigned integer
00343 typedef unsigned char ON__UINT8;
00344 
00345 // 16 bit integer
00346 typedef short ON__INT16;
00347 
00348 // 16 bit unsigned integer
00349 typedef unsigned short ON__UINT16;
00350 
00351 // 32 bit integer
00352 typedef int ON__INT32;
00353 
00354 // 32 bit unsigned integer
00355 typedef unsigned int ON__UINT32;
00356 
00357 #if defined(ON_COMPILER_MSC)
00358 
00359 // Microsoft uses __int64
00360 
00361 // 64 bit integer
00362 typedef __int64 ON__INT64;
00363 
00364 // 64 bit unsigned integer
00365 typedef unsigned __int64 ON__UINT64;
00366 
00367 #elif defined(ON_COMPILER_GNU)
00368 
00369 // GNU uses long long
00370 
00371 // 64 bit integer
00372 typedef long long ON__INT64;
00373 
00374 // 64 bit unsigned integer
00375 typedef unsigned long long ON__UINT64;
00376 
00377 #else
00378 
00379 #error Verify that long long is a 64 bit integer with your compiler!
00380 
00381 // 64 bit integer
00382 typedef long long ON__INT64;
00383 
00384 // 64 bit unsigned integer
00385 typedef unsigned long long ON__UINT64;
00386 
00387 #endif
00388 
00389 // 32 bit boolean (true/false) value
00390 // When we can break the SDK, this will be replaced with "bool", which is 1 byte on windows.
00391 typedef int ON_BOOL32;
00392 
00393 // ON_INT_PTR must be an integer type with sizeof(ON_INT_PTR) = sizeof(void*).
00394 #if 8 == ON_SIZEOF_POINTER
00395 
00396 #if defined(ON_COMPILER_GNU)
00397 typedef long long ON__INT_PTR;
00398 typedef unsigned long long ON__UINT_PTR;
00399 #else
00400 typedef __int64 ON__INT_PTR;
00401 typedef unsigned __int64 ON__UINT_PTR;
00402 #endif
00403 
00404 #elif 4 == ON_SIZEOF_POINTER
00405 
00406 typedef int ON__INT_PTR;
00407 typedef unsigned int ON__UINT_PTR;
00408 
00409 #else
00410 #error Update OpenNURBS to work with new pointer size.
00411 #endif
00412 
00413 
00414 
00415 // In some functions, performance is slightly increased 
00416 // when the endianess of the CPU is known at compile time.
00417 // If the endianness is not known, it is quickly detected
00418 // at runtime and all opennurbs code still works.
00419 //
00420 // If ON_LITTLE_ENDIAN is defined, then the code will
00421 // is compiled assuming little endian byte order.
00422 //
00423 // If ON_BIG_ENDIAN is defined, then the code will
00424 // is compiled assuming big endian byte order.
00425 //
00426 // If neither is defined, the endianess is determined at
00427 // runtime.
00428 //
00429 // If both are defined, a compile error occures.
00430 
00431 #if defined(ON_OS_WINDOWS) && defined(ON_COMPILER_MSC)
00432 
00433 #if defined(_M_X64) || defined(_M_IX86)
00434 #if !defined(ON_LITTLE_ENDIAN)
00435 #define ON_LITTLE_ENDIAN
00436 #endif
00437 #endif
00438 
00439 #endif
00440 
00441 #if defined(ON_COMPILER_XCODE)
00442 /* using Apple's OSX XCode compiler */
00443 
00444 #if (defined(__ppc__) || defined(__ppc64__))
00445 #define ON_BIG_ENDIAN
00446 #elif (defined (__i386__) || defined( __x86_64__ ))
00447 #define ON_LITTLE_ENDIAN
00448 #endif
00449 
00450 #endif
00451 
00452 
00453 #if defined(ON_LITTLE_ENDIAN) && defined(ON_BIG_ENDIAN)
00454 #error At most one of ON_LITTLE_ENDIAN and ON_BIG_ENDIAN can be defined.
00455 #endif
00456 
00457 
00458 // on_vsnprintf()/on_vsnwprintf() call _vsnprintf()/_vsnwprintf() in Windows
00459 // and something equivalent in other OSs
00460 
00461 int on_vsnprintf( char *buffer, size_t count, const char *format, va_list argptr );
00462 
00463 int on_vsnwprintf( wchar_t *buffer, size_t count, const wchar_t *format, va_list argptr );
00464 
00465 
00466 #endif
00467 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:03