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