Point Cloud Library (PCL)  1.14.1-dev
opennurbs_system.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 /*
18 ////////////////////////////////////////////////////////////////
19 //
20 // Includes all system headers required to use the openNURBS toolkit.
21 //
22 ////////////////////////////////////////////////////////////////
23 */
24 
25 #if !defined(OPENNURBS_SYSTEM_INC_)
26 #define OPENNURBS_SYSTEM_INC_
27 
28 // The public release of opennurbs as a source code C++
29 // library is built with OPENNURBS_PUBLIC_RELEASE
30 // defined.
31 #define OPENNURBS_PUBLIC_RELEASE
32 
33 /* compiler choice */
34 #if defined(_MSC_VER)
35 
36 #if defined(OPENNURBS_EXPORTS)
37 // "OPENNURBS_EXPORTS" is Microsoft's prefered define to indicate
38 // an opennurbs DLL is being compiled.
39 #if !defined(ON_DLL_EXPORTS)
40 #define ON_DLL_EXPORTS
41 #endif
42 #if !defined(ON_COMPILING_OPENNURBS)
43 #define ON_COMPILING_OPENNURBS
44 #endif
45 #endif
46 
47 #if defined(OPENNURBS_IMPORTS)
48 // "OPENNURBS_IMPORTS" is Microsoft's prefered define to indicate
49 // an opennurbs DLL is being linked with.
50 #if !defined(ON_DLL_IMPORTS)
51 #define ON_DLL_IMPORTS
52 #endif
53 #endif
54 
55 /* using a Microsoft compiler */
56 #define ON_COMPILER_MSC
57 
58 #if _MSC_VER >= 1300
59 #define ON_COMPILER_MSC1300
60 // If you are using VC7/.NET and are having trouble linking
61 // to functions that have whcar_t types in arguments, then
62 // read the documentation about the wchar_t type and
63 // the /Zc:wchar_t compiler option.
64 
65 #if _MSC_VER >= 1400
66 // Using at least Visual C++ 8.0 (2005)
67 #define ON_COMPILER_MSC1400
68 
69 
70 #if _MSC_VER >= 1600
71 // Using at least Visual C++ 10.0 (2010)
72 #define ON_COMPILER_MSC1600
73 #endif
74 
75 // We are using /W4 wrning levels and disable
76 // these warnings. I would prefer to use
77 // /W3 and enable the level 4 warnings we want,
78 // but microsoft does not have a way to use pragmas
79 // to enable specific warnings.
80 
81 #if defined(ON_COMPILING_OPENNURBS)
82 #pragma warning(disable:4100) // C4100: 'identifier' : unreferenced formal parameter
83 #endif
84 
85 #if !defined(_CRT_SECURE_NO_DEPRECATE)
86 #define _CRT_SECURE_NO_DEPRECATE
87 // Visual Studio 2005 issues a C4996 warning for lots of
88 // standard C runtime functions that take string pointers.
89 // The _CRT_SECURE_NO_DEPRECATE suppresses these warnings.
90 // If you are an IT manager type and really care about these
91 // sorts of things, then comment out the define.
92 #endif
93 
94 #endif
95 
96 #endif
97 
98 #endif
99 
100 #if defined(__GNUG_) || defined(__GNUG__) || defined(__GNUC_) || defined(__GNUC__) || defined(_GNU_SOURCE) || defined(__GNU_SOURCE)
101 /* using Gnu's compiler */
102 #if !defined(ON_COMPILER_GNU)
103 #define ON_COMPILER_GNU
104 #endif
105 #if !defined(_GNU_SOURCE)
106 #define _GNU_SOURCE
107 #endif
108 #endif
109 
110 
111 #if defined(_GNU_SOURCE) && defined(__APPLE__)
112 /* using Apple's OSX XCode compiler */
113 #if !defined(ON_COMPILER_XCODE)
114 #define ON_COMPILER_XCODE
115 #endif
116 #endif
117 
118 #if defined(__BORLANDC__)
119 /* using Borland's compiler */
120 #define ON_COMPILER_BORLAND
121 #endif
122 
123 /*
124 // Define ON_NO_WINDOWS if you are compiling on a Windows system but want
125 // to explicitly exclude inclusion of windows.h.
126 */
127 
128 #if !defined(ON_NO_WINDOWS)
129 
130 /*
131 /////////////////////////////////////////////////////////////////////////
132 //
133 // Begin Windows system includes -
134 */
135 #if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64)
136 
137 #if defined(_M_X64) && defined(WIN32) && defined(WIN64)
138 // 23 August 2007 Dale Lear
139 
140 //#if defined(_INC_WINDOWS)
141 // The user has included Microsoft's windows.h before opennurbs.h,
142 // and windows.h has nested includes that unconditionally define WIN32.
143 // Just undo the damage here or everybody that includes opennurbs.h after
144 // windows.h has to fight with this Microsoft bug.
145 #undef WIN32
146 //#else
147 //#error do not define WIN32 for x64 builds
148 //#endif
149 
150 // NOTE _WIN32 is defined for any type of Windows build
151 #endif
152 
153 /*
154 // From windows.h openNURBS only needs definitions of ON_BOOL32, true,
155 // and false, and a declarations of OutputDebugString(), and
156 // WideCharToMultiByte(). These
157 // defines disable the inclusion of most of the Windows garbage.
158 */
159 
160 #if defined(ON_COMPILER_MSC1600)
161 // include SKDDDKVer.h When using the v100 platform headers.
162 // Including SDKDDKVer.h defines the highest available Windows platform.
163 // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
164 // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
165 //#include <SDKDDKVer.h>
166 #endif
167 
168 #if !defined(_WINDOWS_)
169 /* windows.h has not been read - read just what we need */
170 #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
171 #include <windows.h>
172 #endif
173 
174 #if defined(_M_X64) && defined(WIN32) && defined(WIN64)
175 // 23 August 2007 Dale Lear
176 // windows.h unconditionally defines WIN32 This is a bug
177 // and the hope is this simple undef will let us continue.
178 #undef WIN32
179 #endif
180 
181 /*
182 // if ON_OS_WINDOWS is defined, debugging and error
183 // handing uses some Windows calls and ON_String
184 // includes resource support.
185 */
186 
187 #if !defined(ON_OS_WINDOWS)
188 #define ON_OS_WINDOWS
189 #endif
190 
191 #if defined(ON_OS_WINDOWS) && !defined(NOGDI)
192 // ok to use Windows GDI RECT, LOGFONT, ... stucts.
193 #define ON_OS_WINDOWS_GDI
194 #endif
195 
196 #if defined(_MSC_VER)
197 /*
198  Microsoft's Visual C/C++ requires some functions, including those that
199  use vargs to be declared with __cdecl
200  Since this code must also compile with non-Micorosoft compilers,
201  the ON_MSC_CDECL macro is used to insert __cdecl when needed.
202 */
203 #define ON_MSC_CDECL __cdecl
204 
205 #endif
206 
207 #endif
208 
209 #endif
210 
211 // NOTE: Do not use rand_s() - it crashes Win2000.
212 //
213 //#if defined(_MSC_VER) && !defined(_CRT_RAND_S)
214 //// In order to get high quality random numbers out of
215 //// Microsoft Visual Studio, you have to define _CRT_RAND_S
216 //// before including system header files.
217 //#define _CRT_RAND_S
218 //#endif
219 
220 #include <stdlib.h>
221 #include <memory.h>
222 #if defined(ON_COMPILER_XCODE)
223 #include <malloc/malloc.h>
224 #else
225 #include <malloc.h>
226 #endif
227 #include <string.h>
228 #include <math.h>
229 #include <stdio.h>
230 #include <stdarg.h>
231 #include <float.h>
232 #include <time.h>
233 #include <limits.h>
234 #include <ctype.h>
235 
236 #if defined(ON_COMPILER_IRIX)
237 #include <alloca.h>
238 #endif
239 
240 #if !defined(ON_COMPILER_BORLAND)
241 #include <wchar.h>
242 #endif
243 
244 #if defined(ON_OS_WINDOWS)
245 #include <io.h>
246 #include <sys/stat.h>
247 #include <tchar.h>
248 
249 // ON_CreateUuid calls Windows's ::UuidCreate() which
250 // is declared in Rpcdce.h and defined in Rpcrt4.lib.
251 #include <Rpc.h>
252 
253 #endif
254 
255 #if defined(ON_COMPILER_GNU)
256 #include <sys/types.h>
257 #include <sys/stat.h>
258 #include <wctype.h>
259 #include <dirent.h>
260 #if defined(ON_COMPILER_XCODE)
261 #include <uuid/uuid.h>
262 #endif
263 #endif
264 
265 #include <errno.h>
266 
267 #if defined (cplusplus) || defined(_cplusplus) || defined(__cplusplus)
268 // C++ system includes
269 
270 #if !defined(ON_CPLUSPLUS)
271 #define ON_CPLUSPLUS
272 #endif
273 
274 #include <new> // for declaration of placement versions of new used in onClassArray<>.
275 
276 #endif
277 
278 #if !defined(ON_MSC_CDECL)
279 #define ON_MSC_CDECL
280 #endif
281 
282 #if !defined(ON_OS_WINDOWS) && !defined(_GNU_SOURCE) && !defined(ON_COMPILER_XCODE)
283 
284 /* define wchar_t, true, false, NULL */
285 
286 #if !defined(true)
287 #define true true
288 #endif
289 
290 #if !defined(false)
291 #define false false
292 #endif
293 
294 #if !defined(NULL)
295 #define NULL 0
296 #endif
297 
298 #if !defined(_WCHAR_T_DEFINED)
299 // If you are using VC7/.NET and are having trouble linking
300 // to functions that have whcar_t types in arguments, then
301 // read the documentation about the wchar_t type and
302 // the /Zc:wchar_t compiler option. Since
303 
304 /* 16-bit wide character ("UNICODE") */
305 
306 #if !defined(_WCHAR_T)
307 typedef unsigned short wchar_t;
308 #endif
309 
310 #define _WCHAR_T_DEFINED
311 #endif
312 
313 #endif
314 
315 
316 // As 64 bit compilers become more common, the definitions
317 // of the next 6 typedefs may need to vary with compiler.
318 // As much as possible, the size of runtime types is left
319 // up to the compiler so performance and ease of use can
320 // be maximized. In the rare cases where it is critical
321 // to use an integer that is exactly 16 bits, 32 bits
322 // or 64 bits, the ON__INT16, ON__INT32, and ON__INT64
323 // typedefs are used.
324 
325 #if defined(_M_X64) || defined(_WIN64) || defined(__LP64__)
326 // 64 bit (8 byte) pointers
327 #define ON_SIZEOF_POINTER 8
328 #define ON_64BIT_POINTER
329 // ON_MAX_SIZET = maximum value of a size_t type
330 #define ON_MAX_SIZE_T 0xFFFFFFFFFFFFFFFF
331 #else
332 // 32 bit (4 byte) pointers
333 #define ON_SIZEOF_POINTER 4
334 #define ON_32BIT_POINTER
335 // ON_MAX_SIZET = maximum value of a size_t type
336 #define ON_MAX_SIZE_T 0xFFFFFFFF
337 #endif
338 
339 // 8 bit integer
340 typedef char ON__INT8;
341 
342 // 8 bit unsigned integer
343 typedef unsigned char ON__UINT8;
344 
345 // 16 bit integer
346 typedef short ON__INT16;
347 
348 // 16 bit unsigned integer
349 typedef unsigned short ON__UINT16;
350 
351 // 32 bit integer
352 typedef int ON__INT32;
353 
354 // 32 bit unsigned integer
355 typedef unsigned int ON__UINT32;
356 
357 #if defined(ON_COMPILER_MSC)
358 
359 // Microsoft uses __int64
360 
361 // 64 bit integer
362 typedef __int64 ON__INT64;
363 
364 // 64 bit unsigned integer
365 typedef unsigned __int64 ON__UINT64;
366 
367 #elif defined(ON_COMPILER_GNU)
368 
369 // GNU uses long long
370 
371 // 64 bit integer
372 typedef long long ON__INT64;
373 
374 // 64 bit unsigned integer
375 typedef unsigned long long ON__UINT64;
376 
377 #else
378 
379 #error Verify that long long is a 64 bit integer with your compiler!
380 
381 // 64 bit integer
382 typedef long long ON__INT64;
383 
384 // 64 bit unsigned integer
385 typedef unsigned long long ON__UINT64;
386 
387 #endif
388 
389 // 32 bit boolean (true/false) value
390 // When we can break the SDK, this will be replaced with "bool", which is 1 byte on windows.
391 typedef int ON_BOOL32;
392 
393 // ON_INT_PTR must be an integer type with sizeof(ON_INT_PTR) = sizeof(void*).
394 #if 8 == ON_SIZEOF_POINTER
395 
396 #if defined(ON_COMPILER_GNU)
397 typedef long long ON__INT_PTR;
398 typedef unsigned long long ON__UINT_PTR;
399 #else
400 typedef __int64 ON__INT_PTR;
401 typedef unsigned __int64 ON__UINT_PTR;
402 #endif
403 
404 #elif 4 == ON_SIZEOF_POINTER
405 
406 typedef int ON__INT_PTR;
407 typedef unsigned int ON__UINT_PTR;
408 
409 #else
410 #error Update OpenNURBS to work with new pointer size.
411 #endif
412 
413 
414 
415 // In some functions, performance is slightly increased
416 // when the endianess of the CPU is known at compile time.
417 // If the endianness is not known, it is quickly detected
418 // at runtime and all opennurbs code still works.
419 //
420 // If ON_LITTLE_ENDIAN is defined, then the code will
421 // is compiled assuming little endian byte order.
422 //
423 // If ON_BIG_ENDIAN is defined, then the code will
424 // is compiled assuming big endian byte order.
425 //
426 // If neither is defined, the endianess is determined at
427 // runtime.
428 //
429 // If both are defined, a compile error occures.
430 
431 #if defined(ON_OS_WINDOWS) && defined(ON_COMPILER_MSC)
432 
433 #if defined(_M_X64) || defined(_M_IX86)
434 #if !defined(ON_LITTLE_ENDIAN)
435 #define ON_LITTLE_ENDIAN
436 #endif
437 #endif
438 
439 #endif
440 
441 #if defined(ON_COMPILER_XCODE)
442 /* using Apple's OSX XCode compiler */
443 
444 #if (defined(__ppc__) || defined(__ppc64__))
445 #define ON_BIG_ENDIAN
446 #elif (defined (__i386__) || defined( __x86_64__ ))
447 #define ON_LITTLE_ENDIAN
448 #endif
449 
450 #endif
451 
452 
453 #if defined(ON_LITTLE_ENDIAN) && defined(ON_BIG_ENDIAN)
454 #error At most one of ON_LITTLE_ENDIAN and ON_BIG_ENDIAN can be defined.
455 #endif
456 
457 
458 // on_vsnprintf()/on_vsnwprintf() call _vsnprintf()/_vsnwprintf() in Windows
459 // and something equivalent in other OSs
460 
461 int on_vsnprintf( char *buffer, size_t count, const char *format, va_list argptr );
462 
463 int on_vsnwprintf( wchar_t *buffer, size_t count, const wchar_t *format, va_list argptr );
464 
465 
466 #endif
467 
Defines functions, macros and traits for allocating and using memory.