ovr_sdk

view LibOVR/Src/Kernel/OVR_Compiler.h @ 0:1b39a1b46319

initial 0.4.4
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 14 Jan 2015 06:51:16 +0200
parents
children
line source
1 /************************************************************************************
3 PublicHeader: OVR.h
4 Filename : OVR_Compiler.h
5 Content : Compiler-specific feature identification and utilities
6 Created : June 19, 2014
7 Notes :
9 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
11 Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
12 you may not use the Oculus VR Rift SDK except in compliance with the License,
13 which is provided at the time of installation or download, or which
14 otherwise accompanies this software in either electronic or hard copy form.
16 You may obtain a copy of the License at
18 http://www.oculusvr.com/licenses/LICENSE-3.2
20 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 distributed under the License is distributed on an "AS IS" BASIS,
22 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 See the License for the specific language governing permissions and
24 limitations under the License.
26 ************************************************************************************/
29 #ifndef OVR_Compiler_h
30 #define OVR_Compiler_h
32 #pragma once
35 // References
36 // https://gcc.gnu.org/projects/cxx0x.html
37 // https://gcc.gnu.org/projects/cxx1y.html
38 // http://clang.llvm.org/cxx_status.html
39 // http://msdn.microsoft.com/en-us/library/hh567368.aspx
40 // https://docs.google.com/spreadsheet/pub?key=0AoBblDsbooe4dHZuVTRoSTFBejk5eFBfVk1GWlE5UlE&output=html
41 // http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
44 //-----------------------------------------------------------------------------------
45 // ***** Compiler
46 //
47 // The following compilers are defined: (OVR_CC_x)
48 //
49 // MSVC - Microsoft Visual C/C++
50 // INTEL - Intel C++ for Linux / Windows
51 // GNU - GNU C++
52 // ARM - ARM C/C++
54 #if defined(__INTEL_COMPILER)
55 // Intel 4.0 = 400
56 // Intel 5.0 = 500
57 // Intel 6.0 = 600
58 // Intel 8.0 = 800
59 // Intel 9.0 = 900
60 # define OVR_CC_INTEL __INTEL_COMPILER
62 #elif defined(_MSC_VER)
63 // MSVC 5.0 = 1100
64 // MSVC 6.0 = 1200
65 // MSVC 7.0 (VC2002) = 1300
66 // MSVC 7.1 (VC2003) = 1310
67 // MSVC 8.0 (VC2005) = 1400
68 // MSVC 9.0 (VC2008) = 1500
69 // MSVC 10.0 (VC2010) = 1600
70 // MSVC 11.0 (VC2012) = 1700
71 // MSVC 12.0 (VC2013) = 1800
72 # define OVR_CC_MSVC _MSC_VER
74 #if _MSC_VER == 0x1600
75 # if _MSC_FULL_VER < 160040219
76 # error "Oculus does not support VS2010 without SP1 installed."
77 # endif
78 #endif
80 #elif defined(__GNUC__)
81 # define OVR_CC_GNU
83 #elif defined(__clang__)
84 # define OVR_CC_CLANG
86 #elif defined(__CC_ARM)
87 # define OVR_CC_ARM
89 #else
90 # error "Oculus does not support this Compiler"
91 #endif
94 //-----------------------------------------------------------------------------------
95 // ***** OVR_CC_VERSION
96 //
97 // M = major version
98 // m = minor version
99 // p = patch release
100 // b = build number
101 //
102 // Compiler Format Example
103 // ----------------------------
104 // OVR_CC_GNU Mmm 408 means GCC 4.8
105 // OVR_CC_CLANG Mmm 305 means clang 3.5
106 // OVR_CC_MSVC MMMM 1700 means VS2012
107 // OVR_CC_ARM Mmpbbb 401677 means 4.0, patch 1, build 677
108 // OVR_CC_INTEL MMmm 1210 means 12.10
109 // OVR_CC_EDG Mmm 407 means EDG 4.7
110 //
111 #if defined(OVR_CC_GNU)
112 #define OVR_CC_VERSION ((__GNUC__ * 100) + __GNUC_MINOR__)
113 #elif defined(OVR_CC_CLANG)
114 #define OVR_CC_VERSION ((__clang_major__ * 100) + __clang_minor__)
115 #elif defined(OVR_CC_MSVC)
116 #define OVR_CC_VERSION _MSC_VER // Question: Should we recognize _MSC_FULL_VER?
117 #elif defined(OVR_CC_ARM)
118 #define OVR_CC_VERSION __ARMCC_VERSION
119 #elif defined(OVR_CC_INTEL)
120 #if defined(__INTEL_COMPILER)
121 #define OVR_CC_VERSION __INTEL_COMPILER
122 #elif defined(__ICL)
123 #define OVR_CC_VERSION __ICL
124 #elif defined(__ICC)
125 #define OVR_CC_VERSION __ICC
126 #elif defined(__ECC)
127 #define OVR_CC_VERSION __ECC
128 #endif
129 #elif defined(OVR_CC_EDG)
130 #define OVR_CC_VERSION __EDG_VERSION__ // This is a generic fallback for EDG-based compilers which aren't specified above (e.g. as OVR_CC_ARM)
131 #endif
135 // -----------------------------------------------------------------------------------
136 // ***** OVR_DISABLE_OPTIMIZATION / OVR_RESTORE_OPTIMIZATION
137 //
138 // Allows for the dynamic disabling and restoring of compiler optimizations in code.
139 // This is useful for helping deal with potential compiler code generation problems.
140 // With VC++ the usage must be outside of function bodies. This can be used only to
141 // temporarily disable optimization for a block of code and not to temporarily enable
142 // optimization for a block of code.
143 //
144 // Clang doesn't support this as of June 2014, though function __attribute__((optimize(0))
145 // is supposedly supported by clang in addition to GCC. To consider: Make a wrapper for
146 // this attribute-based functionality.
147 //
148 // Example usage:
149 // OVR_DISABLE_OPTIMIZATION()
150 // void Test() { ... }
151 // OVR_RESTORE_OPTIMIZATION()
152 //
153 #if !defined(OVR_DISABLE_OPTIMIZATION)
154 #if defined(OVR_CC_GNU) && (OVR_CC_VERSION > 404) && (defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64))
155 #define OVR_DISABLE_OPTIMIZATION() \
156 _Pragma("GCC push_options") \
157 _Pragma("GCC optimize 0")
158 #elif defined(OVR_CC_MSVC)
159 #define OVR_DISABLE_OPTIMIZATION() __pragma(optimize("", off))
160 #else
161 #define OVR_DISABLE_OPTIMIZATION()
162 #endif
163 #endif
165 #if !defined(OVR_RESTORE_OPTIMIZATION)
166 #if defined(OVR_CC_GNU) && (OVR_CC_VERSION > 404) && (defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64))
167 #define OVR_RESTORE_OPTIMIZATION() _Pragma("GCC pop_options")
168 #elif defined(OVR_CC_MSVC)
169 #define OVR_RESTORE_OPTIMIZATION() __pragma(optimize("", on))
170 #else
171 #define OVR_RESTORE_OPTIMIZATION()
172 #endif
173 #endif
176 // -----------------------------------------------------------------------------------
177 // ***** OVR_DISABLE_GNU_WARNING / OVR_RESTORE_GNU_WARNING
178 //
179 // Portable wrapper for disabling GCC compiler warnings, one at a time. See example
180 // usage for usage by example.
181 //
182 // Example usage:
183 // OVR_DISABLE_GNU_WARNING(-Wmissing-braces) // Only one warning per usage.
184 // OVR_DISABLE_GNU_WARNING(-Wunused-variable)
185 // <code>
186 // OVR_RESTORE_GNU_WARNINGS()
187 // OVR_RESTORE_GNU_WARNINGS() // Must match each disable with a restore.
188 //
189 #if !defined(OVR_DISABLE_GNU_WARNING)
190 #if defined(OVR_CC_GNU)
191 #define ODGW1(x) #x
192 #define ODGW2(x) ODGW1(GCC diagnostic ignored x)
193 #define ODGW3(x) ODGW2(#x)
194 #endif
196 #if defined(OVR_CC_GNU) && (OVR_CC_VERSION >= 406)
197 #define OVR_DISABLE_GNU_WARNING(w) \
198 _Pragma("GCC diagnostic push") \
199 _Pragma(ODGW3(w))
200 #elif defined(OVR_CC_GNU) && (OVR_CC_VERSION >= 404) // GCC 4.4 doesn't support diagnostic push, but supports disabling warnings.
201 #define OVR_DISABLE_GNU_WARNING(w) \
202 _Pragma(ODGW3(w))
203 #else
204 #define OVR_DISABLE_GNU_WARNING(w)
205 #endif
206 #endif
208 #if !defined(OVR_RESTORE_GNU_WARNING)
209 #if defined(OVR_CC_GNU) && (OVR_CC_VERSION >= 4006)
210 #define OVR_RESTORE_GNU_WARNINGS() \
211 _Pragma("GCC diagnostic pop")
212 #else
213 #define OVR_RESTORE_GNU_WARNING()
214 #endif
215 #endif
219 // -----------------------------------------------------------------------------------
220 // ***** OVR_DISABLE_CLANG_WARNING / OVR_RESTORE_CLANG_WARNING
221 //
222 // Portable wrapper for disabling GCC compiler warnings, one at a time. See example
223 // usage for usage by example.
224 //
225 // Example usage:
226 // OVR_DISABLE_CLANG_WARNING(-Wmissing-braces) // Only one warning per usage.
227 // OVR_DISABLE_CLANG_WARNING(-Wunused-variable)
228 // <code>
229 // OVR_RESTORE_CLANG_WARNINGS()
230 // OVR_RESTORE_CLANG_WARNINGS() // Must match each disable with a restore.
231 //
232 //
233 #if !defined(OVR_DISABLE_CLANG_WARNING)
234 #if defined(OVR_CC_CLANG)
235 #define ODCW1(x) #x
236 #define ODCW2(x) ODCW1(clang diagnostic ignored x)
237 #define ODCW3(x) ODCW2(#x)
239 #define OVR_DISABLE_CLANG_WARNING(w) \
240 _Pragma("clang diagnostic push") \
241 _Pragma(ODCW3(w))
242 #else
243 #define OVR_DISABLE_CLANG_WARNING(w)
244 #endif
245 #endif
247 #if !defined(OVR_RESTORE_CLANG_WARNING)
248 #if defined(OVR_CC_CLANG)
249 #define OVR_RESTORE_CLANG_WARNING() \
250 _Pragma("clang diagnostic pop")
251 #else
252 #define OVR_RESTORE_CLANG_WARNING()
253 #endif
254 #endif
257 // -----------------------------------------------------------------------------------
258 // ***** OVR_DISABLE_MSVC_WARNING / OVR_RESTORE_MSVC_WARNING
259 //
260 // Portable wrapper for disabling VC++ compiler warnings. See example usage for usage
261 // by example.
262 //
263 // Example usage:
264 // OVR_DISABLE_MSVC_WARNING(4556 4782 4422)
265 // <code>
266 // OVR_RESTORE_MSVC_WARNING()
267 //
268 #if !defined(OVR_DISABLE_MSVC_WARNING)
269 #if defined(OVR_CC_MSVC)
270 #define OVR_DISABLE_MSVC_WARNING(w) \
271 __pragma(warning(push)) \
272 __pragma(warning(disable:w))
273 #else
274 #define OVR_DISABLE_MSVC_WARNING(w)
275 #endif
276 #endif
278 #if !defined(OVR_RESTORE_MSVC_WARNING)
279 #if defined(OVR_CC_MSVC)
280 #define OVR_RESTORE_MSVC_WARNING() \
281 __pragma(warning(pop))
282 #else
283 #define OVR_RESTORE_MSVC_WARNING()
284 #endif
285 #endif
288 // -----------------------------------------------------------------------------------
289 // ***** OVR_DISABLE_ALL_MSVC_WARNINGS / OVR_RESTORE_ALL_MSVC_WARNINGS
290 //
291 // Portable wrapper for disabling all VC++ compiler warnings.
292 // OVR_RESTORE_ALL_MSVC_WARNINGS restores warnings that were disabled by
293 // OVR_DISABLE_ALL_MSVC_WARNINGS. Any previously enabled warnings will still be
294 // enabled after OVR_RESTORE_ALL_MSVC_WARNINGS.
295 //
296 // Example usage:
297 // OVR_DISABLE_ALL_MSVC_WARNINGS()
298 // <code>
299 // OVR_RESTORE_ALL_MSVC_WARNINGS()
301 #if !defined(OVR_DISABLE_ALL_MSVC_WARNINGS)
302 #if defined(OVR_CC_MSVC)
303 #define OVR_DISABLE_ALL_MSVC_WARNINGS() \
304 __pragma(warning(push, 0))
305 #else
306 #define OVR_DISABLE_ALL_MSVC_WARNINGS()
307 #endif
308 #endif
310 #if !defined(OVR_RESTORE_ALL_MSVC_WARNINGS)
311 #if defined(OVR_CC_MSVC)
312 #define OVR_RESTORE_ALL_MSVC_WARNINGS() \
313 __pragma(warning(pop))
314 #else
315 #define OVR_RESTORE_ALL_MSVC_WARNINGS()
316 #endif
317 #endif
320 //-----------------------------------------------------------------------------------
321 // ***** OVR_CC_HAS_FEATURE
322 //
323 // This is a portable way to use compile-time feature identification available
324 // with some compilers in a clean way. Direct usage of __has_feature in preprocessing
325 // statements of non-supporting compilers results in a preprocessing error.
326 //
327 // Example usage:
328 // #if OVR_CC_HAS_FEATURE(is_pod)
329 // if(__is_pod(T)) // If the type is plain data then we can safely memcpy it.
330 // memcpy(&destObject, &srcObject, sizeof(object));
331 // #endif
332 //
333 #if !defined(OVR_CC_HAS_FEATURE)
334 #if defined(__clang__) // http://clang.llvm.org/docs/LanguageExtensions.html#id2
335 #define OVR_CC_HAS_FEATURE(x) __has_feature(x)
336 #else
337 #define OVR_CC_HAS_FEATURE(x) 0
338 #endif
339 #endif
342 //-----------------------------------------------------------------------------------
343 // ***** OVR_CC_HAS_BUILTIN
344 //
345 //
346 // This is a portable way to use compile-time builtin identification available
347 // with some compilers in a clean way. Direct usage of __has_builtin in preprocessing
348 // statements of non-supporting compilers results in a preprocessing error.
349 //
350 // Example usage:
351 // #if OVR_CC_HAS_BUILTIN(__builtin_trap)
352 // #define DEBUG_BREAK __builtin_trap
353 // #endif
354 //
355 #if !defined(OVR_CC_HAS_BUILTIN)
356 #if defined(__clang__)
357 #define OVR_CC_HAS_BUILTIN(x) __has_builtin(x) // http://clang.llvm.org/docs/LanguageExtensions.html#id2
358 #else
359 #define OVR_CC_HAS_BUILTIN(x) 0
360 #endif
361 #endif
364 //-----------------------------------------------------------------------------------
365 // ***** OVR_CPP11_ENABLED / OVR_CPP_CPP14_ENABLED
366 //
367 // Defined as 1 if the compiler has its available C++11 support enabled, else undefined.
368 // This does not mean that all of C++11 or any particular feature of C++11 is supported
369 // by the compiler. It means that whatever C++11 support the compiler has is enabled.
370 // This also includes existing and older compilers that still identify C++11 as C++0x.
371 //
372 #if !defined(OVR_CPP11_ENABLED) && defined(__cplusplus)
373 #if defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
374 #define OVR_CPP11_ENABLED 1
375 #elif defined(_MSC_VER) && (_MSC_VER >= 1500) // VS2010+, the first version with any significant C++11 support.
376 #define OVR_CPP11_ENABLED 1
377 #elif (__cplusplus >= 201103L) // 201103 is the first C++11 version.
378 #define OVR_CPP11_ENABLED 1
379 #else
380 // Leave undefined
381 #endif
382 #endif
384 #if !defined(OVR_CPP_CPP14_ENABLED) && defined(__cplusplus)
385 #if defined(_MSC_VER) && (_MSC_VER >= 1800) // VS2013+, the first version with any significant C++14 support.
386 #define OVR_CPP_CPP14_ENABLED 1
387 #elif (__cplusplus > 201103L)
388 #define OVR_CPP_CPP14_ENABLED 1
389 #else
390 // Leave undefined
391 #endif
392 #endif
395 //-----------------------------------------------------------------------------------
396 // ***** OVR_CPP_NO_EXCEPTIONS / OVR_CPP_NO_UNWIND
397 //
398 // OVR_CPP_NO_EXCEPTIONS is defined as 1 if the compiler doesn't support C++
399 // exceptions or is configured to disable support for them. Else not defined.
400 // If OVR_CPP_NO_EXCEPTIONS is defined then attempts to use try/catch
401 // related C++ statements result in a compilation error with many
402 // compilers.
403 //
404 // OVR_CPP_NO_UNWIND is defined as 1 if the compiler supports exceptions but
405 // doesn't support stack unwinding in the presence of an exception. Else not defined.
406 // For the Microsoft compiler, disabling exceptions means disabling stack unwinding
407 // and not disabling exceptions themselves.
408 //
409 // Example usage:
410 // void Test() {
411 // #if !defined(OVR_CPP_NO_EXCEPTIONS)
412 // try {
413 // #endif
414 // void* ptr = new Object;
415 // #if !defined(OVR_CPP_NO_EXCEPTIONS)
416 // catch(...) { ... }
417 // #endif
419 #if !defined(OVR_CPP_NO_EXCEPTIONS)
420 #if defined(OVR_CPP_GNUC) && defined(_NO_EX)
421 #define OVR_CPP_NO_EXCEPTIONS 1
422 #elif (defined(OVR_CC_GNU) || defined(OVR_CC_CLANG) || defined(OVR_CC_INTEL) || defined(OVR_CC_ARM)) && !defined(__EXCEPTIONS)
423 #define OVR_CPP_NO_EXCEPTIONS 1
424 #elif defined(OVR_CC_MSVC) && !defined(_CPPUNWIND)
425 #define OVR_CPP_NO_UNWIND 1
426 #endif
427 #endif
430 //-----------------------------------------------------------------------------------
431 // ***** OVR_CPP_NO_RTTI
432 //
433 // Defined as 1 if C++ run-time type information support is unavailable or disabled
434 // by the compiler. Else undefined. Allows you to write portable code in the face
435 // of the possibility that RTTI is disabled.
436 //
437 // Example usage:
438 // #if !OVR_CPP_NO_RTTI
439 // #include <typeinfo>
440 // int x = std::dynamic_cast<int>(3.4f);
441 // #endif
443 #if defined(__clang__) && !OVR_CC_HAS_FEATURE(cxx_rtti)
444 #define OVR_CPP_NO_RTTI 1
445 #elif defined(__GNUC__) && !defined(__GXX_RTTI)
446 #define OVR_CPP_NO_RTTI 1
447 #elif defined(_MSC_VER) && !defined(_CPPRTTI)
448 #define OVR_CPP_NO_RTTI 1
449 #elif defined(__CC_ARM) && defined(__TARGET_CPU_MPCORE) && !defined(__RTTI)
450 #define OVR_CPP_NO_RTTI 1
451 #endif
454 //-----------------------------------------------------------------------------------
455 // ***** OVR_CPP_NO_STATIC_ASSERT
456 //
457 // Defined as 1 if C++ run-time type information support is available and enabled
458 // by the compiler. Else undefined.
459 //
460 // Example usage:
461 // #if OVR_CPP_NO_STATIC_ASSERT
462 // #define MY_ASSERT(x) { int zero = 0; switch(zero) {case 0: case (x):;} }
463 // #else
464 // #define MY_ASSERT(x) static_assert((x), #x)
465 // #endif
467 #if !defined(OVR_CPP_NO_STATIC_ASSERT)
468 #if !(defined(__GNUC__) && (defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && (__cplusplus >= 201103L)))) && \
469 !(defined(__clang__) && defined(__cplusplus) && OVR_CC_HAS_FEATURE(cxx_static_assert)) && \
470 !(defined(_MSC_VER) && (_MSC_VER >= 1600) && defined(__cplusplus)) && /* VS2010+ */ \
471 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401) && defined(OVR_CPP11_ENABLED)) /* EDG 4.1+ */
472 #define OVR_CPP_NO_STATIC_ASSERT 1
473 #endif
474 #endif
477 //-----------------------------------------------------------------------------------
478 // ***** OVR_CPP_NO_NULLPTR
479 //
480 // Defined as 1 if the compiler doesn't support C++11 nullptr built in type.
481 // Otherwise undefined. Does not identify if the standard library defines
482 // std::nullptr_t, as some standard libraries are further behind in standardization
483 // than the compilers using them (e.g. Apple clang with the supplied libstdc++).
484 //
485 // OVR_Nullptr.h provides a portable nullptr and std::nullptr_t for when the
486 // compiler or standard library do not.
488 #if !defined(OVR_CPP_NO_NULLPTR)
489 #if !defined(OVR_CPP11_ENABLED) || \
490 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_nullptr)) /* clang */ && \
491 !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \
492 !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \
493 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403))) /* EDG 4.3+ */
494 #define OVR_CPP_NO_NULLPTR 1
495 #endif
496 #endif
499 //-----------------------------------------------------------------------------------
500 // ***** OVR_CPP_NO_RVALUE_REFERENCES
501 //
502 // Defined as 1 if the compiler doesn't support C++11 rvalue references and move semantics.
503 // Otherwise undefined.
505 #if !defined(OVR_CPP_NO_RVALUE_REFERENCES)
506 #if !defined(OVR_CPP11_ENABLED) || \
507 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_rvalue_references)) /* clang */ && \
508 !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \
509 !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \
510 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403))) /* EDG 4.3+ */
511 #define OVR_CPP_NO_RVALUE_REFERENCES 1
512 #endif
513 #endif
516 //-----------------------------------------------------------------------------------
517 // ***** OVR_CPP_NO_AUTO
518 //
519 // Defined as 1 if the compiler doesn't support C++11 auto keyword. Otherwise undefined.
521 #if !defined(OVR_CPP_NO_AUTO)
522 #if !defined(OVR_CPP11_ENABLED) || \
523 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_auto_type)) /* clang */ && \
524 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
525 !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \
526 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 309))) /* EDG 3.9+ */
527 #define OVR_CPP_NO_AUTO 1
528 #endif
529 #endif
532 //-----------------------------------------------------------------------------------
533 // ***** OVR_CPP_NO_RANGE_BASED_FOR_LOOP
534 //
535 // Defined as 1 if the compiler doesn't support C++11 range-based for loops.
536 // Otherwise undefined.
538 #if !defined(OVR_CPP_NO_RANGE_BASED_FOR_LOOP)
539 #if !defined(OVR_CPP11_ENABLED) || \
540 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_range_for)) /* clang */ && \
541 !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \
542 !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2012+ */ && \
543 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */
544 #define OVR_CPP_NO_RANGE_BASED_FOR_LOOP 1
545 #endif
546 #endif
549 //-----------------------------------------------------------------------------------
550 // ***** OVR_CPP_NO_CONSTEXPR / OVR_CPP_NO_RELAXED_CONSTEXPR
551 //
552 // OVR_CPP_NO_CONSTEXPR is defined as 1 if the compiler doesn't support C++11 constexpr.
553 // OVR_CPP_NO_RELAXED_CONSTEXPR is defined as 1 if the compiler doesn't support C++14 constexpr.
554 // Otherwise undefined.
555 // See the OVR_CONSTEXPR / OVR_CONSTEXPR_OR_CONST macros for portable wrappers of this functionality.
557 #if !defined(OVR_CPP_NO_CONSTEXPR)
558 #if !defined(OVR_CPP11_ENABLED) || \
559 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_constexpr)) /* clang */ && \
560 !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \
561 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */
562 // Not supported by VC++ through at least VS2013.
563 #define OVR_CPP_NO_CONSTEXPR 1
564 #endif
565 #endif
567 #if !defined(OVR_CPP_NO_RELAXED_CONSTEXPR)
568 #if !defined(OVR_CPP14_ENABLED) || \
569 !(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_relaxed_constexpr)) /* clang */
570 // Supported only by clang as of this writing.
571 #define OVR_CPP_NO_RELAXED_CONSTEXPR 1
572 #endif
573 #endif
576 //-----------------------------------------------------------------------------------
577 // ***** OVR_CPP_NO_LAMBDA_EXPRESSIONS
578 //
579 // Defined as 1 if the compiler doesn't support C++11 lambda expressions. Otherwise undefined.
580 // Some compilers have slightly crippled versions of this.
582 #if !defined(OVR_CPP_NO_LAMBDA_EXPRESSIONS)
583 #if !defined(OVR_CPP11_ENABLED) || \
584 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_lambdas)) /* clang */ && \
585 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
586 !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \
587 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */
588 // Conversion of lambdas to function pointers is not supported until EDG 4.5.
589 #define OVR_CPP_NO_LAMBDA_EXPRESSIONS 1
590 #endif
591 #endif
594 //-----------------------------------------------------------------------------------
595 // ***** OVR_CPP_NO_ALIGNOF
596 //
597 // Defined as 1 if the compiler supports C++11 alignof. Otherwise undefined.
598 // Some compilers support __alignof__ instead of alignof, so for portability you
599 // should use OVR_ALIGNOF instead of directly using C++11 alignof.
601 #if !defined(OVR_CPP_NO_ALIGNOF)
602 #if !defined(OVR_CPP11_ENABLED) || \
603 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \
604 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 300)) /* Apple clang 3.0+ */ && \
605 !(defined(__GNUC__) && (OVR_CC_VERSION >= 401)) /* GCC 4.1+ */ && \
606 !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \
607 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 400))) /* EDG 4.0+ */
608 #define OVR_CPP_NO_ALIGNOF 1
609 #endif
610 #endif
613 //-----------------------------------------------------------------------------------
614 // ***** OVR_CPP_NO_ALIGNAS
615 //
616 // Defined as 1 if the compiler supports C++11 alignas. Otherwise undefined.
617 // See the OVR_ALIGNAS for a portable wrapper for alignas functionality.
619 #if !defined(OVR_CPP_NO_ALIGNAS)
620 #if !defined(OVR_CPP11_ENABLED) || \
621 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 300)) /* clang 3.0+ */ && \
622 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
623 !(defined(__GNUC__) && (OVR_CC_VERSION >= 408)) /* GCC 4.8+ */ && \
624 !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \
625 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */
626 #define OVR_CPP_NO_ALIGNAS 1
627 #endif
628 #endif
631 //-----------------------------------------------------------------------------------
632 // ***** OVR_CPP_NO_OVERRIDE
633 //
634 // Defined as 1 if the compiler doesn't support C++11 override. Otherwise undefined.
635 // See the OVR_OVERRIDE and OVR_FINALOVERRIDE macros for a portable wrapper.
637 #if !defined(OOVR_CPP_NO_OVERRIDE)
638 #if !defined(OVR_CPP11_ENABLED) || \
639 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \
640 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \
641 !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \
642 !(defined(_MSC_VER) && (_MSC_VER >= 1500)) /* VS2008+ */ && \
643 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */
644 #define OVR_CPP_NO_OVERRIDE 1
645 #endif
646 #endif
649 //-----------------------------------------------------------------------------------
650 // ***** OVR_CPP_NO_FINAL
651 //
652 // Defined as 1 if the compiler doesn't support C++11 final attribute. Otherwise undefined.
653 // See the OVR_FINAL and OVR_FINALOVERRIDE macros for a portable wrapper.
655 #if !defined(OOVR_CPP_NO_FINAL)
656 #if !defined(OVR_CPP11_ENABLED) || \
657 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \
658 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \
659 !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \
660 !(defined(_MSC_VER) && (_MSC_VER >= 1500)) /* VS2008+ */ && \
661 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */
662 #define OVR_CPP_NO_FINAL 1
663 #endif
664 #endif
667 //-----------------------------------------------------------------------------------
668 // ***** OVR_CPP_NO_EXTERN_TEMPLATE
669 //
670 // Defined as 1 if the compiler doesn't support C++11 extern template.
671 // Otherwise undefined. See OVR_EXTERN_TEMPLATE for wrapper macro.
673 #if !defined(OVR_CPP_NO_EXTERN_TEMPLATE)
674 #if !defined(OVR_CPP11_ENABLED) || \
675 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \
676 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
677 !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \
678 !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2012+ */ && \
679 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */
680 #define OVR_CPP_NO_EXTERN_TEMPLATE 1
681 #endif
682 #endif
685 //-----------------------------------------------------------------------------------
686 // ***** OVR_CPP_NO_VARIADIC_TEMPLATES
687 //
688 // Defined as 1 if the compiler doesn't support C++11 variadic templates. Otherwise undefined.
690 #if !defined(OVR_CPP_NO_VARIADIC_TEMPLATES)
691 #if !defined(OVR_CPP11_ENABLED) || \
692 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_variadic_templates)) /* clang */ && \
693 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
694 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
695 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403))) /* EDG 4.3+ */
696 #define OVR_CPP_NO_VARIADIC_TEMPLATES 1
697 #endif
698 #endif
701 //-----------------------------------------------------------------------------------
702 // ***** OVR_CPP_NO_NOEXCEPT
703 //
704 // Defined as 1 if the compiler supports C++11 noexcept. Otherwise undefined.
705 // http://en.cppreference.com/w/cpp/language/noexcept
706 // See OVR_NOEXCEPT / OVR_NOEXCEPT_IF / OVR_NOEXCEPT_EXPR for a portable wrapper
707 // for noexcept functionality.
709 #if !defined(OVR_CPP_NO_NOEXCEPT)
710 #if !defined(OVR_CPP11_ENABLED) || \
711 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_noexcept)) /* clang */ && \
712 !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \
713 !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \
714 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */
715 #define OVR_CPP_NO_NOEXCEPT 1
716 #endif
717 #endif
720 //-----------------------------------------------------------------------------------
721 // ***** OVR_CPP_NO_DECLTYPE
722 //
723 // Defined as 1 if the compiler doesn't support C++11 decltype. Otherwise undefined.
724 // Some compilers (e.g. VS2012) support most uses of decltype but don't support
725 // decltype with incomplete types (which is an uncommon usage seen usually in
726 // template metaprogramming). We don't include this support as a requirement for
727 // our definition of decltype support here.
729 #if !defined(OVR_CPP_NO_DECLTYPE)
730 #if !defined(OVR_CPP11_ENABLED) || \
731 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_decltype)) /* clang */ && \
732 !(defined(__GNUC__) && (OVR_CC_VERSION >= 403)) /* GCC 4.3+ */ && \
733 !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \
734 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 402))) /* EDG 4.2+ */
735 // VC++ fails to support decltype for incomplete types until VS2013.
736 // EDG fails to support decltype for incomplete types until v4.8.
737 #define OVR_CPP_NO_DECLTYPE 1
738 #endif
739 #endif
742 //-----------------------------------------------------------------------------------
743 // ***** OVR_CPP_NO_DEFAULTED_FUNCTIONS
744 //
745 // Defined as 1 if the compiler doesn't support C++11 defaulted functions. Otherwise undefined.
746 // Some compilers have slightly crippled versions of this.
748 #if !defined(OVR_CPP_NO_DEFAULTED_FUNCTIONS)
749 #if !defined(OVR_CPP11_ENABLED) || \
750 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_defaulted_functions))/* clang */ && \
751 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
752 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
753 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */
754 // Up through at least VS2013 it's unsupported for defaulted move constructors and move assignment operators.
755 // Until EDG 4.8 it's unsupported for defaulted move constructors and move assigment operators.
756 #define OVR_CPP_NO_DEFAULTED_FUNCTIONS 1
757 #endif
758 #endif
761 //-----------------------------------------------------------------------------------
762 // ***** OVR_CPP_NO_DELETED_FUNCTIONS
763 //
764 // Defined as 1 if the compiler doesn't support C++11 deleted functions. Otherwise undefined.
765 // Some compilers have slightly crippled versions of this.
767 #if !defined(OVR_CPP_NO_DELETED_FUNCTIONS)
768 #if !defined(OVR_CPP11_ENABLED) || \
769 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_defaulted_functions)) /* clang */ && \
770 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
771 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
772 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */
773 // Up through at least VS2013 it's unsupported for defaulted move constructors and move assignment operators.
774 // Until EDG 4.8 it's unsupported for defaulted move constructors and move assigment operators.
775 #define OVR_CPP_NO_DELETED_FUNCTIONS 1
776 #endif
777 #endif
780 //-----------------------------------------------------------------------------------
781 // ***** OVR_CPP_NO_STANDARD_LAYOUT_TYPES
782 //
783 // Defined as 1 if the compiler doesn't support C++11 standard layout (relaxed POD). Otherwise undefined.
784 // http://en.cppreference.com/w/cpp/types/is_standard_layout
786 #if !defined(OVR_CPP_NO_STANDARD_LAYOUT_TYPES)
787 #if !defined(OVR_CPP11_ENABLED) || \
788 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 300)) /* clang 3.0+ */ && \
789 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
790 !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \
791 !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2013+ */ && \
792 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */
793 #define OVR_CPP_NO_STANDARD_LAYOUT_TYPES 1
794 #endif
795 #endif
798 //-----------------------------------------------------------------------------------
799 // ***** OVR_CPP_NO_FORWARD_DECLARED_ENUMS
800 //
801 // Defined as 1 if the compiler doesn't support C++11 forward declared enums. Otherwise undefined.
803 #if !defined(OVR_CPP_NO_FORWARD_DECLARED_ENUMS)
804 #if !defined(OVR_CPP11_ENABLED) || \
805 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \
806 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
807 !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \
808 !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2012+ */ && \
809 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */
810 #define OVR_CPP_NO_FORWARD_DECLARED_ENUMS 1
811 #endif
812 #endif
815 //-----------------------------------------------------------------------------------
816 // ***** OVR_CPP_NO_STRONGLY_TYPED_ENUMS
817 //
818 // Defined as 1 if the compiler doesn't support C++11 strongly typed enums. Otherwise undefined.
820 #if !defined(OVR_CPP_NO_STRONGLY_TYPED_ENUMS)
821 #if !defined(OVR_CPP11_ENABLED) || \
822 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_strong_enums)) /* clang */ && \
823 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
824 !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2012+ */ && \
825 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 400))) /* EDG 4.0+ */
826 #define OVR_CPP_NO_STRONGLY_TYPED_ENUMS 1
827 #endif
828 #endif
831 //-----------------------------------------------------------------------------------
832 // ***** OVR_CPP_NO_TRAILING_RETURN_TYPES
833 //
834 // Defined as 1 if the compiler doesn't support C++11 trailing return types. Otherwise undefined.
835 // http://en.wikipedia.org/wiki/C%2B%2B11#Alternative_function_syntax
837 #if !defined(OVR_CPP_NO_TRAILING_RETURN_TYPES)
838 #if !defined(OVR_CPP11_ENABLED) || \
839 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_trailing_return)) /* clang */ && \
840 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
841 !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \
842 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */
843 #define OVR_CPP_NO_TRAILING_RETURN_TYPES 1
844 #endif
845 #endif
848 //-----------------------------------------------------------------------------------
849 // ***** OVR_CPP_NO_TEMPLATE_ALIASES
850 //
851 // Defined as 1 if the compiler doesn't support C++11 template aliases. Otherwise undefined.
853 #if !defined(OVR_CPP_NO_TEMPLATE_ALIASES)
854 #if !defined(OVR_CPP11_ENABLED) || \
855 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_alias_templates)) /* clang */ && \
856 !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \
857 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
858 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 402))) /* EDG 4.2+ */
859 #define OVR_CPP_NO_TEMPLATE_ALIASES 1
860 #endif
861 #endif
864 //-----------------------------------------------------------------------------------
865 // ***** OVR_CPP_NO_INITIALIZER_LISTS
866 //
867 // Defined as 1 if the compiler doesn't support C++11 initializer lists. Otherwise undefined.
868 // This refers to the compiler support for this and not the Standard Library support for std::initializer_list,
869 // as a new compiler with an old standard library (e.g. Apple clang with libstdc++) may not support std::initializer_list.
871 #if !defined(OVR_CPP_NO_INITIALIZER_LISTS)
872 #if !defined(OVR_CPP11_ENABLED) || \
873 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_generalized_initializers)) /* clang */ && \
874 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
875 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
876 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */
877 #define OVR_CPP_NO_INITIALIZER_LISTS 1
878 #endif
879 #endif
882 //-----------------------------------------------------------------------------------
883 // ***** OVR_CPP_NO_NORETURN
884 //
885 // Defined as 1 if the compiler doesn't support the C++11 noreturn attribute. Otherwise undefined.
886 // http://en.cppreference.com/w/cpp/language/attributes
887 //
888 #if !defined(OVR_CPP_NO_NORETURN)
889 #if !defined(OVR_CPP11_ENABLED) || \
890 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \
891 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
892 !(defined(__GNUC__) && (OVR_CC_VERSION >= 408)) /* GCC 4.8+ */ && \
893 !(defined(_MSC_VER) && (_MSC_VER >= 1500)) /* VS2008+ */ && \
894 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 402))) /* EDG 4.2+ */
895 // Supported with VC++ only via __declspec(noreturn) (see OVR_NORETURN).
896 #define OVR_CPP_NO_NORETURN 1
897 #endif
898 #endif
901 //-----------------------------------------------------------------------------------
902 // ***** OVR_CPP_NO_NONSTATIC_MEMBER_INITIALIZERS
903 //
904 // Defined as 1 if the compiler doesn't support C++11 in-class non-static member initializers. Otherwise undefined.
905 // http://en.cppreference.com/w/cpp/language/data_members
907 #if !defined(OVR_CPP_NO_NONSTATIC_MEMBER_INITIALIZERS)
908 #if !defined(OVR_CPP11_ENABLED) || \
909 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \
910 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
911 !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \
912 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
913 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */
914 #define OVR_CPP_NO_NONSTATIC_MEMBER_INITIALIZERS 1
915 #endif
916 #endif
919 //-----------------------------------------------------------------------------------
920 // ***** OVR_CPP_NO_DOUBLE_TEMPLATE_BRACKETS
921 //
922 // Defined as 1 if the compiler supports nested template declarations with >>,
923 // as supported by C++11. Otherwise undefined.
925 #if !defined(OVR_CPP_NO_DOUBLE_TEMPLATE_ANGLE_BRACKETS)
926 #if !defined(OVR_CPP11_ENABLED) || \
927 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \
928 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \
929 !(defined(__GNUC__) && (OVR_CC_VERSION >= 403)) /* GCC 4.3+ */ && \
930 !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \
931 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */
932 #define OVR_CPP_NO_DOUBLE_TEMPLATE_BRACKETS 1
933 #endif
934 #endif
938 //-----------------------------------------------------------------------------------
939 // ***** OVR_CPP_NO_INHERITING_CONSTRUCTORS
940 //
941 // Defined as 1 if the compiler supports C++11 inheriting constructors. Otherwise undefined.
942 // Example usage:
943 // struct A { explicit A(int x){} };
944 // struct B : public A { using A::A; }; // As if B redeclared A::A(int).
946 #if !defined(OVR_CPP_NO_INHERITING_CONSTRUCTORS)
947 #if !defined(OVR_CPP11_ENABLED) || \
948 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_inheriting_constructors)) /* clang */ && \
949 !(defined(__GNUC__) && (OVR_CC_VERSION >= 408)) /* GCC 4.8+ */ && \
950 !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \
951 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */
952 #define OVR_CPP_NO_INHERITING_CONSTRUCTORS 1
953 #endif
954 #endif
957 //-----------------------------------------------------------------------------------
958 // ***** OVR_CPP_NO_DELEGATING_CONSTRUCTORS
959 //
960 // Defined as 1 if the compiler supports C++11 delegating constructors. Otherwise undefined.
962 #if !defined(OVR_CPP_NO_DELEGATING_CONSTRUCTORS)
963 #if !defined(OVR_CPP11_ENABLED) || \
964 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 300)) /* clang 3.0+ */ && \
965 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
966 !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \
967 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
968 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 407))) /* EDG 4.7+ */
969 #define OVR_CPP_NO_DELEGATING_CONSTRUCTORS 1
970 #endif
971 #endif
974 //-----------------------------------------------------------------------------------
975 // ***** OVR_CPP_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS
976 //
977 // Defined as 1 if the compiler supports C++11 function template default arguments. Otherwise undefined.
979 #if !defined(OVR_CPP_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS)
980 #if !defined(OVR_CPP11_ENABLED) || \
981 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \
982 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.0+ */ && \
983 !(defined(__GNUC__) && (OVR_CC_VERSION >= 403)) /* GCC 4.3+ */ && \
984 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
985 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403))) /* EDG 4.3+ */
986 #define OVR_CPP_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS 1
987 #endif
988 #endif
991 //-----------------------------------------------------------------------------------
992 // ***** OVR_CPP_NO_UNRESTRICTED_UNIONS
993 //
994 // Defined as 1 if the compiler supports C++11 unrestricted unions. Otherwise undefined.
996 #if !defined(OVR_CPP_NO_UNRESTRICTED_UNIONS)
997 #if !defined(OVR_CPP11_ENABLED) || \
998 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \
999 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
1000 !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \
1001 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */
1002 // Not supported by VC++ as of VS2013.
1003 #define OVR_CPP_NO_UNRESTRICTED_UNIONS 1
1004 #endif
1005 #endif
1009 //-----------------------------------------------------------------------------------
1010 // ***** OVR_CPP_NO_EXTENDED_SIZEOF
1011 //
1012 // Defined as 1 if the compiler supports C++11 class sizeof extensions (e.g. sizeof SomeClass::someMember).
1013 // Otherwise undefined.
1015 #if !defined(OVR_CPP_NO_EXTENDED_SIZEOF)
1016 #if !defined(OVR_CPP11_ENABLED) || \
1017 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \
1018 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
1019 !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \
1020 !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \
1021 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */
1022 #define OVR_CPP_NO_EXTENDED_SIZEOF 1
1023 #endif
1024 #endif
1027 //-----------------------------------------------------------------------------------
1028 // ***** OVR_CPP_NO_INLINE_NAMESPACES
1029 //
1030 // Defined as 1 if the compiler supports C++11 inlined namespaces. Otherwise undefined.
1031 // http://en.cppreference.com/w/cpp/language/namespace#Inline_namespaces
1033 #if !defined(OVR_CPP_NO_INLINE_NAMESPACES)
1034 #if !defined(OVR_CPP11_ENABLED) || \
1035 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \
1036 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \
1037 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
1038 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */
1039 // Not supported by VC++ as of VS2013.
1040 #define OVR_CPP_NO_INLINE_NAMESPACES 1
1041 #endif
1042 #endif
1045 //-----------------------------------------------------------------------------------
1046 // ***** OVR_CPP_NO_EXPLICIT_CONVERSION_OPERATORS
1047 //
1048 // Defined as 1 if the compiler supports C++11 explicit conversion operators. Otherwise undefined.
1049 // http://en.cppreference.com/w/cpp/language/explicit
1051 #if !defined(OVR_CPP_NO_EXPLICIT_CONVERSION_OPERATORS)
1052 #if !defined(OVR_CPP11_ENABLED) || \
1053 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_explicit_conversions)) /* clang */ && \
1054 !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \
1055 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
1056 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 404))) /* EDG 4.4+ */
1057 #define OVR_CPP_NO_EXPLICIT_CONVERSION_OPERATORS 1
1058 #endif
1059 #endif
1062 //-----------------------------------------------------------------------------------
1063 // ***** OVR_CPP_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS
1064 //
1065 // Defined as 1 if the compiler supports C++11 local class template parameters. Otherwise undefined.
1066 // Example:
1067 // void Test() {
1068 // struct LocalClass{ };
1069 // SomeTemplateClass<LocalClass> t; // Allowed only in C++11
1070 // }
1072 #if !defined(OVR_CPP_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS)
1073 #if !defined(OVR_CPP11_ENABLED) || \
1074 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_local_type_template_args)) /* clang */ && \
1075 !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \
1076 !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \
1077 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 402))) /* EDG 4.2+ */
1078 #define OVR_CPP_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS 1
1079 #endif
1080 #endif
1083 //-----------------------------------------------------------------------------------
1084 // ***** OVR_CPP_NO_NEW_CHARACTER_TYPES
1085 //
1086 // Defined as 1 if the compiler natively supports C++11 char16_t and char32_t. Otherwise undefined.
1087 // VC++ through at least VS2013 defines char16_t as unsigned short in its standard library,
1088 // but it is not a native type or unique type, nor can you for a string literal with it.
1090 #if !defined(OVR_CPP_NO_NEW_CHARACTER_TYPES)
1091 #if !defined(OVR_CPP11_ENABLED) || \
1092 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_unicode_literals)) /* clang */ && \
1093 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
1094 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 407))) /* EDG 4.7+ */
1095 // Not supported by VC++ as of VS2013.
1096 #define OVR_CPP_NO_NEW_CHARACTER_TYPES 1
1097 #endif
1098 #endif
1101 //-----------------------------------------------------------------------------------
1102 // ***** OVR_CPP_NO_UNICODE_CHAR_NAME_LITERALS
1103 //
1104 // Defined as 1 if the compiler supports C++11 \u and \U character literals for
1105 // native char16_t and char32_t types.
1106 //
1107 #if !defined(OVR_CPP_NO_UNICODE_CHAR_NAME_LITERALS)
1108 #if !defined(OVR_CPP11_ENABLED) || \
1109 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \
1110 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
1111 !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \
1112 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */
1113 // Not supported by VC++ as of VS2013. VC++'s existing \U and \u are non-conforming.
1114 #define OVR_CPP_NO_UNICODE_CHAR_NAME_LITERALS 1
1115 #endif
1116 #endif
1119 //-----------------------------------------------------------------------------------
1120 // ***** OVR_CPP_NO_USER_DEFINED_LITERALS
1121 //
1122 // Defined as 1 if the compiler supports C++11 user-defined literals. Otherwise undefined.
1124 #if !defined(OVR_CPP_NO_USER_DEFINED_LITERALS)
1125 #if !defined(OVR_CPP11_ENABLED) || \
1126 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \
1127 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \
1128 !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \
1129 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */
1130 // Not supported by VC++ as of VS2013.
1131 #define OVR_CPP_NO_USER_DEFINED_LITERALS 1
1132 #endif
1133 #endif
1136 //-----------------------------------------------------------------------------------
1137 // ***** OVR_CPP_NO_UNICODE_STRING_LITERALS
1138 //
1139 // Defined as 1 if the compiler supports C++11 Unicode string literals. Otherwise undefined.
1140 // http://en.wikipedia.org/wiki/C%2B%2B11#New_string_literals
1142 #if !defined(OVR_CPP_NO_UNICODE_STRING_LITERALS)
1143 #if !defined(OVR_CPP11_ENABLED) || \
1144 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_unicode_literals)) /* clang */ && \
1145 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
1146 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 407))) /* EDG 4.7+ */
1147 // Not supported by VC++ as of VS2013.
1148 #define OVR_CPP_NO_UNICODE_STRING_LITERALS 1
1149 #endif
1150 #endif
1153 //-----------------------------------------------------------------------------------
1154 // ***** OVR_CPP_NO_RAW_STRING_LITERALS
1155 //
1156 // Defined as 1 if the compiler supports C++11 raw literals. Otherwise undefined.
1157 // http://en.wikipedia.org/wiki/C%2B%2B11#New_string_literals
1159 #if !defined(OVR_CPP_NO_RAW_STRING_LITERALS)
1160 #if !defined(OVR_CPP11_ENABLED) || \
1161 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_raw_string_literals)) /* clang */ && \
1162 !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \
1163 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 407))) /* EDG 4.7+ */
1164 // Not supported by VC++ as of VS2013.
1165 #define OVR_CPP_NO_RAW_STRING_LITERALS 1
1166 #endif
1167 #endif
1170 //-----------------------------------------------------------------------------------
1171 // ***** OVR_CPP_NO_UNIFIED_INITIALIZATION_SYNTAX
1172 //
1173 // Defined as 1 if the compiler supports C++11 unified initialization.
1174 // http://en.wikipedia.org/wiki/C%2B%2B11#Uniform_initialization
1176 #if !defined(OVR_CPP_NO_UNIFIED_INITIALIZATION_SYNTAX)
1177 #if !defined(OVR_CPP11_ENABLED) || \
1178 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_generalized_initializers)) /* clang */ && \
1179 !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \
1180 !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \
1181 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */
1182 #define OVR_CPP_NO_UNIFIED_INITIALIZATION_SYNTAX 1
1183 #endif
1184 #endif
1187 //-----------------------------------------------------------------------------------
1188 // ***** OVR_CPP_NO_EXTENDED_FRIEND_DECLARATIONS
1189 //
1190 // Defined as 1 if the compiler supports C++11 extended friends.
1192 #if !defined(OVR_CPP_NO_EXTENDED_FRIEND_DECLARATIONS)
1193 #if !defined(OVR_CPP11_ENABLED) || \
1194 (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \
1195 !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \
1196 !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \
1197 !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \
1198 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */
1199 #define OVR_CPP_NO_EXTENDED_FRIEND_DECLARATIONS 1
1200 #endif
1201 #endif
1204 //-----------------------------------------------------------------------------------
1205 // ***** OVR_CPP_NO_THREAD_LOCAL
1206 //
1207 // Defined as 1 if the compiler supports C++11 thread_local. Else undefined. Does not
1208 // indicate if the compiler supports C thread-local compiler extensions such as __thread
1209 // and declspec(thread). Use OVR_THREAD_LOCAL if you want to declare a thread-local
1210 // variable that supports C++11 thread_local when available but the C extension when
1211 // it's available. The primary difference between C++11 thread_local and C extensions is
1212 // that C++11 thread_local supports non-PODs and calls their constructors and destructors.
1213 //
1214 // Note that thread_local requires both compiler and linker support, and so it's possible
1215 // that the compiler may support thread_local but the linker does not.
1217 #if !defined(OVR_CPP_NO_THREAD_LOCAL)
1218 #if !defined(OVR_CPP11_ENABLED) || \
1219 (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_thread_local)) /* clang */ && \
1220 !(defined(__GNUC__) && (OVR_CC_VERSION >= 408)) /* GCC 4.8+ */ && \
1221 !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */
1222 #define OVR_CPP_NO_THREAD_LOCAL 1
1223 #endif
1224 #endif
1227 // -----------------------------------------------------------------------------------
1228 // ***** OVR_ALIGNAS / OVR_ALIGNOF
1229 //
1230 // OVR_ALIGNAS(n) // Specifies a size_t power of two alignment for a type or instance.
1231 // OVR_ALIGNOF(type) // Returns the size_t alignment of a type or instance.
1232 //
1233 // Example usage:
1234 // OVR_ALIGNAS(8) char c = 'c'; // Specifies that the instance c be aligned to an 8 byte boundary.
1235 // typedef OVR_ALIGNAS(8) char C; // Specifies that the type C be aligned to an 8 byte boundary.
1236 // struct OVR_ALIGNAS(64) S{ char array[16]; }; // Specfies that the struct S have a natural alignment of 64.
1237 // OVR_ALIGNAS(32) S s; // Specifies that the instance s of struct S be aligned to an 32 byte boundary.
1238 // OVR_ALIGNAS(32) struct T{ char array[16]; } t; // Specfies that the instance t of struct T have a natural alignment of 32.
1239 // struct OVR_ALIGNAS(T) U{}; // Specifes that U be aligned the same as T. Supported only by C++11 compilers (see OVR_CPP_NO_ALIGNAS).
1240 //
1241 // size_t a = OVR_ALIGNOF(double); // Returns the natural alignment of the double type.
1242 // size_t a = OVR_ALIGNOF(S); // Returns the natural alignment of the struct S type.
1243 //
1244 // Note: If C++11 alignas is supported, then alignas/OVR_ALIGNAS may take a const expression in addition to a constant.
1245 // Note: The C11 Standard species the _Alignas keyword and alignas as a macro for it in <stdalign.h>
1247 #if !defined(OVR_ALIGNAS)
1248 #if defined(OVR_CC_GNU) && !defined(OVR_CPP_NO_ALIGNAS) // If C++11 alignas is supported...
1249 #define OVR_ALIGNAS(n) alignas(n)
1250 #elif defined(__clang__) && !defined(OVR_CPP_NO_ALIGNAS)
1251 #define OVR_ALIGNAS(n) alignas(n)
1252 #elif defined(OVR_CC_GNU) || defined(__clang__)
1253 #define OVR_ALIGNAS(n) __attribute__((aligned(n)))
1254 #elif defined(OVR_CC_MSVC) || defined(OVR_CC_INTEL)
1255 #define OVR_ALIGNAS(n) __declspec(align(n)) // For Microsoft the alignment must be a literal integer.
1256 #elif defined(OVR_CC_ARM)
1257 #define OVR_ALIGNAS(n) __align(n)
1258 #else
1259 #error Need to define OVR_ALIGNAS
1260 #endif
1261 #endif
1263 #if !defined(OVR_ALIGNOF)
1264 #if defined(OVR_CC_GNU) && !defined(OVR_CPP_NO_ALIGNOF) // If C++11 alignof is supported...
1265 #define OVR_ALIGNOF(type) alignof(type)
1266 #elif defined(__clang__) && !defined(OVR_CPP_NO_ALIGNOF)
1267 #define OVR_ALIGNOF(type) alignof(type)
1268 #elif defined(OVR_CC_GNU) || defined(__clang__)
1269 #define OVR_ALIGNOF(type) ((size_t)__alignof__(type))
1270 #elif defined(OVR_CC_MSVC) || defined(OVR_CC_INTEL)
1271 #define OVR_ALIGNOF(type) ((size_t)__alignof(type))
1272 #elif defined(OVR_CC_ARM)
1273 #define OVR_ALIGNOF(type) ((size_t)__ALIGNOF__(type))
1274 #else
1275 #error Need to define OVR_ALIGNOF
1276 #endif
1277 #endif
1280 // -----------------------------------------------------------------------------------
1281 // ***** OVR_ASSUME / OVR_ANALYSIS_ASSUME
1282 //
1283 // This is a portable wrapper for VC++'s __assume and __analysis_assume.
1284 // __analysis_assume is typically used to quell VC++ static analysis warnings.
1285 //
1286 // Example usage:
1287 // void Test(char c){
1288 // switch(c){
1289 // case 'a':
1290 // case 'b':
1291 // case 'c':
1292 // case 'd':
1293 // break;
1294 // default:
1295 // OVR_ASSUME(0); // Unreachable code.
1296 // }
1297 // }
1298 //
1299 // size_t Test(char* str){
1300 // OVR_ANALYSIS_ASSUME(str != nullptr);
1301 // return strlen(str);
1302 // }
1304 #if !defined(OVR_ASSUME)
1305 #if defined(OVR_CC_MSVC)
1306 #define OVR_ASSUME(x) __assume(x)
1307 #define OVR_ANALYSIS_ASSUME(x) __analysis_assume(!!(x))
1308 #else
1309 #define OVR_ASSUME(x)
1310 #define OVR_ANALYSIS_ASSUME(x)
1311 #endif
1312 #endif
1315 // -----------------------------------------------------------------------------------
1316 // ***** OVR_RESTRICT
1317 //
1318 // Wraps the C99 restrict keyword in a portable way.
1319 // C++11 and C++14 don't have restrict but this functionality is supported by
1320 // all C++ compilers.
1321 //
1322 // Example usage:
1323 // void* memcpy(void* OVR_RESTRICT s1, const void* OVR_RESTRICT s2, size_t n);
1325 #if !defined(OVR_RESTRICT)
1326 #define OVR_RESTRICT __restrict // Currently supported by all compilers of significance to us.
1327 #endif
1330 // -----------------------------------------------------------------------------------
1331 // ***** OVR_NOEXCEPT / OVR_NOEXCEPT_IF(predicate) / OVR_NOEXCEPT_EXPR(expression)
1332 //
1333 // Implements a portable wrapper for C++11 noexcept.
1334 // http://en.cppreference.com/w/cpp/language/noexcept
1335 //
1336 // Example usage:
1337 // void Test() OVR_NOEXCEPT {} // This function doesn't throw.
1338 //
1339 // template <typename T>
1340 // void DoNothing() OVR_NOEXCEPT_IF(OVR_NOEXCEPT_EXPR(T())) // Throws an if and only if T::T(int) throws.
1341 // { T t(3); }
1342 //
1343 #if !defined(OVR_NOEXCEPT)
1344 #if defined(OVR_CPP_NOEXCEPT)
1345 #define OVR_NOEXCEPT
1346 #define OVR_NOEXCEPT_IF(predicate)
1347 #define OVR_NOEXCEPT_EXPR(expression) false
1348 #else
1349 #define OVR_NOEXCEPT noexcept
1350 #define OVR_NOEXCEPT_IF(predicate) noexcept((predicate))
1351 #define OVR_NOEXCEPT_EXPR(expression) noexcept((expression))
1352 #endif
1353 #endif
1356 // -----------------------------------------------------------------------------------
1357 // ***** OVR_FINAL
1358 //
1359 // Wraps the C++11 final keyword in a portable way.
1360 // http://en.cppreference.com/w/cpp/language/final
1361 //
1362 // Example usage:
1363 // struct Test { virtual int GetValue() OVR_FINAL; };
1365 #if !defined(OVR_FINAL)
1366 #if defined(OVR_CC_MSVC) && (OVR_CC_VERSION < 1700) // VC++ 2012 and earlier
1367 #define OVR_FINAL sealed
1368 #elif defined(OVR_CPP_INHERITANCE_FINAL)
1369 #define OVR_FINAL
1370 #else
1371 #define OVR_FINAL final
1372 #endif
1373 #endif
1376 // -----------------------------------------------------------------------------------
1377 // ***** OVR_OVERRIDE
1378 //
1379 // Wraps the C++11 override keyword in a portable way.
1380 // http://en.cppreference.com/w/cpp/language/override
1381 //
1382 // Example usage:
1383 // struct Parent { virtual void Func(int); };
1384 // struct Child : public Parent { void Func(int) OVR_OVERRIDE; };
1386 #if !defined(OVR_CPP11_ENABLED)
1387 #define OVR_OVERRIDE
1388 #elif !defined(OVR_OVERRIDE)
1389 #if defined(OVR_CPP_OVERRIDE)
1390 #define OVR_OVERRIDE
1391 #else
1392 #if (defined(_MSC_VER) && (_MSC_VER <= 1600))
1393 #pragma warning(disable : 4481)
1394 #endif
1395 #define OVR_OVERRIDE override
1396 #endif
1397 #endif
1400 // -----------------------------------------------------------------------------------
1401 // ***** OVR_FINAL_OVERRIDE
1402 //
1403 // Wraps the C++11 final+override keywords (a common combination) in a portable way.
1404 //
1405 // Example usage:
1406 // struct Parent { virtual void Func(); };
1407 // struct Child : public Parent { virtual void Func() OVR_FINAL_OVERRIDE; };
1409 #if !defined(OVR_FINAL_OVERRIDE)
1410 #define OVR_FINAL_OVERRIDE OVR_FINAL OVR_OVERRIDE
1411 #endif
1414 // -----------------------------------------------------------------------------------
1415 // ***** OVR_EXTERN_TEMPLATE
1416 //
1417 // Portable wrapper for C++11 extern template. This tells the compiler to not instantiate
1418 // the template in the current translation unit, which can significantly speed up
1419 // compilation and avoid problems due to two translation units compiling code with
1420 // different settings.
1421 //
1422 // Example usage:
1423 // OVR_EXTERN_TEMPLATE(class basic_string<char>); // Nothing to do for non-C++11 compilers.
1425 #if !defined(OVR_EXTERN_TEMPLATE)
1426 #if defined(OVR_CPP_EXTERN_TEMPLATE)
1427 #define OVR_EXTERN_TEMPLATE(decl)
1428 #else
1429 #define OVR_EXTERN_TEMPLATE(decl) extern template decl
1430 #endif
1431 #endif
1434 // -----------------------------------------------------------------------------------
1435 // ***** OVR_CONSTEXPR / OVR_CONSTEXPR_OR_CONST
1436 //
1437 // Portable wrapper for C++11 constexpr. Doesn't include C++14 relaxed constexpr,
1438 // for which a different wrapper name is reserved.
1439 //
1440 // Example usage:
1441 // OVR_CONSTEXPR int Test() { return 15; } // This can be optimized better by a C++11 compiler that supports constexpr.
1442 // OVR_CONSTEXPR_OR_CONST float x = 3.14159f; // This can be optimized better by a C++11 compiler, but if not then at least make it const.
1444 #if !defined(OVR_CONSTEXPR)
1445 #if defined(OVR_CPP_NO_CONSTEXPR)
1446 #define OVR_CONSTEXPR
1447 #else
1448 #define OVR_CONSTEXPR constexpr
1449 #endif
1450 #endif
1452 #if !defined(OVR_CONSTEXPR_OR_CONST)
1453 #if defined(OVR_CPP_NO_CONSTEXPR)
1454 #define OVR_CONSTEXPR_OR_CONST const
1455 #else
1456 #define OVR_CONSTEXPR_OR_CONST constexpr
1457 #endif
1458 #endif
1462 // -----------------------------------------------------------------------------------
1463 // ***** OVR_FUNCTION_DELETE / OVR_FUNCTION_DEFAULT
1464 //
1465 // Wraps the C++11 delete and default keywords in a way that allows for cleaner code
1466 // while making for a better version of uncallable or default functions.
1467 //
1468 // Example usage:
1469 // struct Test{
1470 // Test() OVR_FUNCTION_DEFAULT; // Non-C++11 compilers will require a separate definition for Test().
1471 // private: // Users should put OVR_FUNCTION_DELETE usage in a private
1472 // void Uncallable() OVR_FUNCTION_DELETE; // area for compatibility with pre-C++11 compilers.
1473 // };
1475 #if defined(OVR_CPP_NO_DELETED_FUNCTIONS)
1476 #define OVR_FUNCTION_DELETE
1477 #else
1478 #define OVR_FUNCTION_DELETE = delete
1479 #endif
1481 #if defined(OVR_CPP_NO_DEFAULTED_FUNCTIONS)
1482 #define OVR_FUNCTION_DEFAULT
1483 #else
1484 #define OVR_FUNCTION_DEFAULT = default
1485 #endif
1489 // -----------------------------------------------------------------------------------
1490 // ***** OVR_NON_COPYABLE
1491 //
1492 // Allows you to specify a class as being neither copy-constructible nor assignable,
1493 // which is a commonly needed pattern in C++ programming. Classes with this declaration
1494 // are required to be default constructible (as are most classes). For pre-C++11
1495 // compilers this macro declares a private section for the class, which will be
1496 // inherited by whatever code is directly below the macro invocation by default.
1497 //
1498 // Example usage:
1499 // struct Test {
1500 // Test();
1501 // ...
1502 // OVR_NON_COPYABLE(Test)
1503 // };
1505 #if !defined(OVR_NON_COPYABLE)
1506 #if defined(OVR_CPP_NO_DELETED_FUNCTIONS)
1507 #define OVR_NON_COPYABLE(Type) \
1508 private: \
1509 Type(const Type&); \
1510 void operator=(const Type&);
1511 #else
1512 #define OVR_NON_COPYABLE(Type) \
1513 Type(const Type&) = delete; \
1514 void operator=(const Type&) = delete;
1515 #endif
1516 #endif
1520 #endif // header include guard