OVR_Compiler.h 64 KB

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