forked from mcneel/opennurbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopennurbs_system_compiler.h
416 lines (347 loc) · 13 KB
/
opennurbs_system_compiler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
//
// Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved.
// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
// McNeel & Associates.
//
// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
// MERCHANTABILITY ARE HEREBY DISCLAIMED.
//
// For complete openNURBS copyright information see <http://www.opennurbs.org>.
//
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//
// Determines what compiler is being used.
//
////////////////////////////////////////////////////////////////
#if !defined(OPENNURBS_SYSTEM_COMPILER_INC_)
#define OPENNURBS_SYSTEM_COMPILER_INC_
#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE
#endif
/*
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//
// BEGIN - ON_COMPILER_* defines
//
// ON_COMPILER_* specifies the C/C++ compiler used.
// At most one the ON_COMPILER_* should be defined.
//
*/
/*
// Compilers with a better static_assert declaration
// may change ON_STATIC_ASSERT accordingly.
*/
#if __cpp_static_assert >= 201411L // C++17
# define ON_STATIC_ASSERT(expr) static_assert((expr))
# define ON_STATIC_ASSERT_MSG(expr, msg) static_assert((expr), msg)
#elif __cpp_static_assert >= 200410L // C++11
# define ON_STATIC_ASSERT(expr) static_assert((expr), #expr)
# define ON_STATIC_ASSERT_MSG(expr, msg) static_assert((expr), msg)
#else
# define ON_STATIC_ASSERT(expr) typedef char on_static_assert_t[(expr) != 0]
# define ON_STATIC_ASSERT_MSG(expr, msg) typedef char on_static_assert_t[(expr) != 0]
#endif
/*
// Compilers that require special declaration of callback functions
// will change ON_CALLBACK_CDECL accordingly.
*/
#define ON_CALLBACK_CDECL
/*
// Compilers that require special declaration of callback functions
// will change ON_CALLBACK_CDECL accordingly.
*/
#define ON_VARGS_FUNC_CDECL
/*
// Compilers that do not support the C++ 11 noexcept keyword
// or similar will change ON_NOEXCEPT accordingly.
*/
#define ON_NOEXCEPT noexcept
/*
// Compilers that do not support the C++ 11 rvalue refs
// will change ON_HAS_RVALUEREF accordingly.
*/
#define ON_HAS_RVALUEREF
#if defined (_MSC_VER)
/*
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//
// ON_COMPILER_MSC
//
*/
#define ON_COMPILER_MSC
/*
// Usage example - disables warning number 1234 - see CL docs for details
#pragma ON_PRAGMA_WARNING_PUSH
#pragma ON_PRAGMA_WARNING_DISABLE_MSC(1234)
...
#pragma ON_PRAGMA_WARNING_POP
*/
#define ON_PRAGMA_WARNING_PUSH warning( push )
#define ON_PRAGMA_WARNING_POP warning( pop )
#define ON_PRAGMA_WARNING_DISABLE_MSC(ON_PRAGMA_WARNING_DISABLE_param) warning( disable : ON_PRAGMA_WARNING_DISABLE_param ) // Microsoft CL warning disable
// Opennurbs warning level is /Wall
// Microsoft, Freetype, and other external header files issue warnings we can't do anything about
#define ON_PRAGMA_WARNING_BEFORE_DIRTY_INCLUDE warning( push, 1 )
#define ON_PRAGMA_WARNING_AFTER_DIRTY_INCLUDE warning( pop )
#if !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE
/*
// Visual Studio 2005 issues a C4996 warning for lots of
// standard C runtime functions that take string pointers.
// The _CRT_SECURE_NO_DEPRECATE suppresses these warnings.
// TODO - clean up our code and remove do not define _CRT_SECURE_NO_DEPRECATE
*/
#endif
/*
// Microsoft's Visual C/C++ requires functions that use vargs
// to be declared with __cdecl
// Since this code must also compile with non-Micorosoft compilers,
// the ON_VARGS_FUNC_CDECL macro is used to insert __cdecl when needed.
*/
#undef ON_VARGS_FUNC_CDECL
#define ON_VARGS_FUNC_CDECL __cdecl
/*
// Microsoft's Visual C/C++ requires some callback functions
// to be declared with __cdecl
// Since this code must also compile with non-Micorosoft compilers,
// the ON_VARGS_FUNC_CDECL macro is used to insert __cdecl when needed.
*/
#undef ON_CALLBACK_CDECL
#define ON_CALLBACK_CDECL __cdecl
#if _MSC_VER < 1700
#undef ON_HAS_RVALUEREF
#endif
#if _MSC_VER >= 1700 && _MSC_VER < 1900
// VC 2012 and 2013 does not support the C++11 noexcept specifier.
// Appending throw() indicates the function does not throw
// exceptions. Using throw() is not 100% equivalent to
// noexcept because you cannot use a bool parameter
// and hence cannot do things like
// class MyClass : public MyOtherClass
// {
// void MyClass() noexcept(std::is_nothrow_default_constructible<MyOtherClass>::value)
// void MyClass(const MyClass& ) noexcept(std::is_nothrow_copy_constructible<MyOtherClass>::value)
// };
#undef ON_NOEXCEPT
#define ON_NOEXCEPT throw()
#endif
#if _MSC_VER >= 1300
#define ON_COMPILER_MSC1300
#if _MSC_VER >= 1400
/* Using at least Visual C++ 8.0 (2005) */
#define ON_COMPILER_MSC1400
#if _MSC_VER >= 1600
/* Using at least Visual C++ 10.0 (2010) */
#define ON_COMPILER_MSC1600
#if _MSC_VER >= 1700
/* Using at least Visual C++ 11.0 (2012) */
#define ON_COMPILER_MSC1700
#if _MSC_VER >= 1800
/* Using at least Visual C++ 12.0 (2013) */
#define ON_COMPILER_MSC1800
#if _MSC_VER >= 1900
/* Using at least Visual C++ 14.0 (2015) */
#define ON_COMPILER_MSC1900
#if !defined(OPENNURBS_WALL) && !defined(ON_COMPILING_OPENNURBS)
/*
// TEMPORARY C4456 SUPPRESSION Feb 17 2016 - WILL BE REMOVED ASAP
// Rhino code is still too dirty to leave 4456 on.
*/
// Suppress Warning C4456 declaration of '...' hides previous local declaration ...
#pragma ON_PRAGMA_WARNING_DISABLE_MSC(4456)
#endif
// C4100 '...': unreferenced formal parameter ...
#pragma ON_PRAGMA_WARNING_DISABLE_MSC(4100)
// C4061 enumerator '...' in switch of enum '...' is not explicitly handled by a case label
#pragma ON_PRAGMA_WARNING_DISABLE_MSC(4061)
// C4062 enumerator '...' in switch of enum '...' is not handled
#pragma ON_PRAGMA_WARNING_DISABLE_MSC(4062)
// C4711 function '...' selected for inline expansion
#pragma ON_PRAGMA_WARNING_DISABLE_MSC(4711)
// C4820 '...' bytes padding added after construct '...'
#pragma ON_PRAGMA_WARNING_DISABLE_MSC(4820)
/////////////////////////////////////////////////////////////////////////////////////
//
// Dale Lear April 2017.
// The Visual Studio 2017 default is to disable warnings 4263, 4264, 4265, 4266
//
// These are the warnings that help detect abuse of virtual functions and failed attempts
// to override virtual functions.
//
// I've enable them for all Rhino core projects.
// "#pragma warning(default:xxxx): is the way to enable warning xxxx.
//
// 'function' : member function does not override any base class virtual member function
// A class function definition has the same name as a virtual function in a base
// class but not the same number or type of arguments. This effectively hides the
// virtual function in the base class.
#pragma warning(default:4263)
// 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden
#pragma warning(default:4264)
// 'class' : class has virtual functions, but destructor is not virtual
// When a class has virtual functions but a nonvirtual destructor, objects
// of the type might not be destroyed properly when the class is destroyed
// through a base class pointer.
// NOTE WELL: Occasionally there are good reasons to have a non-virtual destructor.
// See Guideline #4 in http://www.gotw.ca/publications/mill18.htm for a nice description of the details.
// However, those case are generally rare and this warning can explicitly be disabled for those rare
// cases.
#pragma warning(default:4265)
#if defined(OPENNURBS_WALL)
// The 4266 warning is enabled only when OPENNURBS_WALL is defined.
//
// In the case of Rhino, this warning is not useful.
// It is reasonable to override some but not all base class virtual functions
// that have the same name.
// For example, almost every class derived from CRhinoObject overrides
// virtual ON_BoundingBox BoundingBox() const;
// but most do not override
// virtual ON_BoundingBox BoundingBox( const class CRhinoViewport* pViewport ) const;
// 'function' : no override available for virtual member function from base 'type'; function is hidden
// A derived class did not override all overloads of a virtual function.
#pragma warning(default:4266)
#endif
//
/////////////////////////////////////////////////////////////////////////////////////
#endif
#endif
#endif
#endif
#endif
#endif
#define ON_SIZEOF_WCHAR_T 2
#elif defined(__clang__) | defined(__clang) | defined(ON_COMPILER_CLANG)
/*
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//
// ON_COMPILER_CLANG
//
*/
/*
// The __clang__ test must come before the gnu tests because Apple's clang
// unconditionally defines __GNUC__
*/
#if !defined(ON_COMPILER_CLANG)
#define ON_COMPILER_CLANG
#endif
/*
// Usage example - disables CLang warning xyz - See CLang docs for warning options
#pragma ON_PRAGMA_WARNING_PUSH
#pragma ON_PRAGMA_WARNING_DISABLE_CLANG("-Wxyz")
...
#pragma ON_PRAGMA_WARNING_POP
*/
#define ON_PRAGMA_WARNING_PUSH clang diagnostic push // Apple CLang warning state push
#define ON_PRAGMA_WARNING_POP clang diagnostic pop // Apple CLang warning state pop
#define ON_PRAGMA_WARNING_DISABLE_CLANG(ON_PRAGMA_WARNING_DISABLE_param) clang diagnostic ignored ON_PRAGMA_WARNING_DISABLE_param // Apple CLang warning disable
#if defined(__has_feature) && __has_feature(cxx_noexcept)
#undef ON_NOEXCEPT
#define ON_NOEXCEPT noexcept
#endif
#if defined(__has_extension) && __has_extension(cxx_rvalue_references) && !defined(ON_HAS_RVALUEREF)
#define ON_HAS_RVALUEREF
#elif defined(ON_HAS_RVALUEREF)
#undef ON_HAS_RVALUEREF
#endif
#elif defined( ON_COMPILER_ANDROIDNDK )
/*
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//
// ON_COMPILER_ANDROIDNDK
//
*/
/*
// McNeel defines ON_COMPILER_ANDROIDNDK in makefiles
*/
#if defined(__GNUC__) && (__GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 7))
// C++11 noexcept and Rvalue references are in gcc 4.7 and later
#undef ON_NOEXCEPT
#define ON_NOEXCEPT noexcept
#if !defined(ON_HAS_RVALUEREF)
#define ON_HAS_RVALUEREF
#endif
#else
#undef ON_HAS_RVALUEREF
#undef ON_NOEXCEPT
#endif
// You may need to define __GXX_EXPERIMENTAL_CXX0X__ to get
// C++11 std::shared_ptr to work as you expect when using
// the Android NDK gcc 4.7. See
// http://stackoverflow.com/questions/14532057/smart-pointers-not-working-with-android-ndk-r8
// for more details.
//
//#define __GXX_EXPERIMENTAL_CXX0X__
#elif defined(__GNUG_) || defined(__GNUG__) || defined(__GNUC_) || defined(__GNUC__) || defined(_GNU_SOURCE) || defined(__GNU_SOURCE)
/*
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//
// ON_COMPILER_GNU
//
*/
#define ON_COMPILER_GNU
#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE
#endif
/*
// Usage example - disables gcc warning xyz - See Gnu gcc docs for warning options
#pragma ON_PRAGMA_WARNING_PUSH
#pragma ON_PRAGMA_WARNING_DISABLE_CLANG("-Wxyx")
...
#pragma ON_PRAGMA_WARNING_POP
*/
#define ON_PRAGMA_WARNING_PUSH GCC diagnostic push // Gnu gcc warning state push
#define ON_PRAGMA_WARNING_POP GCC diagnostic pop // Gnu gcc warning state pop
#define ON_PRAGMA_WARNING_DISABLE_GNU(ON_PRAGMA_WARNING_DISABLE_param) GCC diagnostic ignored ON_PRAGMA_WARNING_DISABLE_param // Apple CLang warning disable
#if defined(__GNUC__) && (__GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 7))
// C++11 noexcept and Rvalue references are in gcc 4.7 and later
#undef ON_NOEXCEPT
#define ON_NOEXCEPT noexcept
#if !defined(ON_HAS_RVALUEREF)
#define ON_HAS_RVALUEREF
#endif
#else
#undef ON_HAS_RVALUEREF
#undef ON_NOEXCEPT
#endif
#elif defined(__BORLANDC__)
/*
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
//
// ON_COMPILER_BORLANDC
//
*/
#define ON_COMPILER_BORLANDC
#endif
/*
These defines will be set to something more appropriate when
opennurbs_system_compiler detects the compiler and platform.
*/
#if !defined(ON_PRAGMA_WARNING_PUSH) && !defined(ON_PRAGMA_WARNING_POP)
#define ON_PRAGMA_WARNING_PUSH
#define ON_PRAGMA_WARNING_POP
#elif !defined(ON_PRAGMA_WARNING_PUSH) || !defined(ON_PRAGMA_WARNING_POP)
#error mistake in the compiler specific define setup above
#endif
#if !defined(ON_PRAGMA_WARNING_DISABLE_MSC)
#define ON_PRAGMA_WARNING_DISABLE_MSC(ON_PRAGMA_WARNING_DISABLE_param)
#endif
#if !defined(ON_PRAGMA_WARNING_DISABLE_CLANG)
#define ON_PRAGMA_WARNING_DISABLE_CLANG(ON_PRAGMA_WARNING_DISABLE_param)
#endif
#if !defined(ON_PRAGMA_WARNING_DISABLE_GNU)
#define ON_PRAGMA_WARNING_DISABLE_GNU(ON_PRAGMA_WARNING_DISABLE_param)
#endif
#if !defined(ON_PRAGMA_WARNING_BEFORE_DIRTY_INCLUDE) && !defined(ON_PRAGMA_WARNING_AFTER_DIRTY_INCLUDE)
#define ON_PRAGMA_WARNING_BEFORE_DIRTY_INCLUDE ON_PRAGMA_WARNING_PUSH
#define ON_PRAGMA_WARNING_AFTER_DIRTY_INCLUDE ON_PRAGMA_WARNING_POP
#endif
#endif