hedley.h 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048
  1. /* Hedley - https://nemequ.github.io/hedley
  2. * Created by Evan Nemerson <[email protected]>
  3. *
  4. * To the extent possible under law, the author(s) have dedicated all
  5. * copyright and related and neighboring rights to this software to
  6. * the public domain worldwide. This software is distributed without
  7. * any warranty.
  8. *
  9. * For details, see <http://creativecommons.org/publicdomain/zero/1.0/>.
  10. * SPDX-License-Identifier: CC0-1.0
  11. */
  12. #if !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < 12)
  13. #if defined(HEDLEY_VERSION)
  14. #undef HEDLEY_VERSION
  15. #endif
  16. #define HEDLEY_VERSION 12
  17. #if defined(HEDLEY_STRINGIFY_EX)
  18. #undef HEDLEY_STRINGIFY_EX
  19. #endif
  20. #define HEDLEY_STRINGIFY_EX(x) #x
  21. #if defined(HEDLEY_STRINGIFY)
  22. #undef HEDLEY_STRINGIFY
  23. #endif
  24. #define HEDLEY_STRINGIFY(x) HEDLEY_STRINGIFY_EX(x)
  25. #if defined(HEDLEY_CONCAT_EX)
  26. #undef HEDLEY_CONCAT_EX
  27. #endif
  28. #define HEDLEY_CONCAT_EX(a, b) a##b
  29. #if defined(HEDLEY_CONCAT)
  30. #undef HEDLEY_CONCAT
  31. #endif
  32. #define HEDLEY_CONCAT(a, b) HEDLEY_CONCAT_EX(a, b)
  33. #if defined(HEDLEY_VERSION_ENCODE)
  34. #undef HEDLEY_VERSION_ENCODE
  35. #endif
  36. #define HEDLEY_VERSION_ENCODE(major, minor, revision) \
  37. (((major)*1000000) + ((minor)*1000) + (revision))
  38. #if defined(HEDLEY_VERSION_DECODE_MAJOR)
  39. #undef HEDLEY_VERSION_DECODE_MAJOR
  40. #endif
  41. #define HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000)
  42. #if defined(HEDLEY_VERSION_DECODE_MINOR)
  43. #undef HEDLEY_VERSION_DECODE_MINOR
  44. #endif
  45. #define HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000)
  46. #if defined(HEDLEY_VERSION_DECODE_REVISION)
  47. #undef HEDLEY_VERSION_DECODE_REVISION
  48. #endif
  49. #define HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000)
  50. #if defined(HEDLEY_GNUC_VERSION)
  51. #undef HEDLEY_GNUC_VERSION
  52. #endif
  53. #if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
  54. #define HEDLEY_GNUC_VERSION \
  55. HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
  56. #elif defined(__GNUC__)
  57. #define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0)
  58. #endif
  59. #if defined(HEDLEY_GNUC_VERSION_CHECK)
  60. #undef HEDLEY_GNUC_VERSION_CHECK
  61. #endif
  62. #if defined(HEDLEY_GNUC_VERSION)
  63. #define HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) \
  64. (HEDLEY_GNUC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  65. #else
  66. #define HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) (0)
  67. #endif
  68. #if defined(HEDLEY_MSVC_VERSION)
  69. #undef HEDLEY_MSVC_VERSION
  70. #endif
  71. #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000)
  72. #define HEDLEY_MSVC_VERSION \
  73. HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, \
  74. (_MSC_FULL_VER % 10000000) / 100000, \
  75. (_MSC_FULL_VER % 100000) / 100)
  76. #elif defined(_MSC_FULL_VER)
  77. #define HEDLEY_MSVC_VERSION \
  78. HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, \
  79. (_MSC_FULL_VER % 1000000) / 10000, \
  80. (_MSC_FULL_VER % 10000) / 10)
  81. #elif defined(_MSC_VER)
  82. #define HEDLEY_MSVC_VERSION \
  83. HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0)
  84. #endif
  85. #if defined(HEDLEY_MSVC_VERSION_CHECK)
  86. #undef HEDLEY_MSVC_VERSION_CHECK
  87. #endif
  88. #if !defined(_MSC_VER)
  89. #define HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) (0)
  90. #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
  91. #define HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) \
  92. (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
  93. #elif defined(_MSC_VER) && (_MSC_VER >= 1200)
  94. #define HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) \
  95. (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
  96. #else
  97. #define HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) \
  98. (_MSC_VER >= ((major * 100) + (minor)))
  99. #endif
  100. #if defined(HEDLEY_INTEL_VERSION)
  101. #undef HEDLEY_INTEL_VERSION
  102. #endif
  103. #if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE)
  104. #define HEDLEY_INTEL_VERSION \
  105. HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, \
  106. __INTEL_COMPILER_UPDATE)
  107. #elif defined(__INTEL_COMPILER)
  108. #define HEDLEY_INTEL_VERSION \
  109. HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
  110. #endif
  111. #if defined(HEDLEY_INTEL_VERSION_CHECK)
  112. #undef HEDLEY_INTEL_VERSION_CHECK
  113. #endif
  114. #if defined(HEDLEY_INTEL_VERSION)
  115. #define HEDLEY_INTEL_VERSION_CHECK(major, minor, patch) \
  116. (HEDLEY_INTEL_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  117. #else
  118. #define HEDLEY_INTEL_VERSION_CHECK(major, minor, patch) (0)
  119. #endif
  120. #if defined(HEDLEY_PGI_VERSION)
  121. #undef HEDLEY_PGI_VERSION
  122. #endif
  123. #if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && \
  124. defined(__PGIC_PATCHLEVEL__)
  125. #define HEDLEY_PGI_VERSION \
  126. HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
  127. #endif
  128. #if defined(HEDLEY_PGI_VERSION_CHECK)
  129. #undef HEDLEY_PGI_VERSION_CHECK
  130. #endif
  131. #if defined(HEDLEY_PGI_VERSION)
  132. #define HEDLEY_PGI_VERSION_CHECK(major, minor, patch) \
  133. (HEDLEY_PGI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  134. #else
  135. #define HEDLEY_PGI_VERSION_CHECK(major, minor, patch) (0)
  136. #endif
  137. #if defined(HEDLEY_SUNPRO_VERSION)
  138. #undef HEDLEY_SUNPRO_VERSION
  139. #endif
  140. #if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
  141. #define HEDLEY_SUNPRO_VERSION \
  142. HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + \
  143. ((__SUNPRO_C >> 12) & 0xf), \
  144. (((__SUNPRO_C >> 8) & 0xf) * 10) + \
  145. ((__SUNPRO_C >> 4) & 0xf), \
  146. (__SUNPRO_C & 0xf) * 10)
  147. #elif defined(__SUNPRO_C)
  148. #define HEDLEY_SUNPRO_VERSION \
  149. HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, \
  150. (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C)&0xf)
  151. #elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
  152. #define HEDLEY_SUNPRO_VERSION \
  153. HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + \
  154. ((__SUNPRO_CC >> 12) & 0xf), \
  155. (((__SUNPRO_CC >> 8) & 0xf) * 10) + \
  156. ((__SUNPRO_CC >> 4) & 0xf), \
  157. (__SUNPRO_CC & 0xf) * 10)
  158. #elif defined(__SUNPRO_CC)
  159. #define HEDLEY_SUNPRO_VERSION \
  160. HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, \
  161. (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC)&0xf)
  162. #endif
  163. #if defined(HEDLEY_SUNPRO_VERSION_CHECK)
  164. #undef HEDLEY_SUNPRO_VERSION_CHECK
  165. #endif
  166. #if defined(HEDLEY_SUNPRO_VERSION)
  167. #define HEDLEY_SUNPRO_VERSION_CHECK(major, minor, patch) \
  168. (HEDLEY_SUNPRO_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  169. #else
  170. #define HEDLEY_SUNPRO_VERSION_CHECK(major, minor, patch) (0)
  171. #endif
  172. #if defined(HEDLEY_EMSCRIPTEN_VERSION)
  173. #undef HEDLEY_EMSCRIPTEN_VERSION
  174. #endif
  175. #if defined(__EMSCRIPTEN__)
  176. #define HEDLEY_EMSCRIPTEN_VERSION \
  177. HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, \
  178. __EMSCRIPTEN_tiny__)
  179. #endif
  180. #if defined(HEDLEY_EMSCRIPTEN_VERSION_CHECK)
  181. #undef HEDLEY_EMSCRIPTEN_VERSION_CHECK
  182. #endif
  183. #if defined(HEDLEY_EMSCRIPTEN_VERSION)
  184. #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major, minor, patch) \
  185. (HEDLEY_EMSCRIPTEN_VERSION >= \
  186. HEDLEY_VERSION_ENCODE(major, minor, patch))
  187. #else
  188. #define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major, minor, patch) (0)
  189. #endif
  190. #if defined(HEDLEY_ARM_VERSION)
  191. #undef HEDLEY_ARM_VERSION
  192. #endif
  193. #if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
  194. #define HEDLEY_ARM_VERSION \
  195. HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, \
  196. (__ARMCOMPILER_VERSION % 1000000) / 10000, \
  197. (__ARMCOMPILER_VERSION % 10000) / 100)
  198. #elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
  199. #define HEDLEY_ARM_VERSION \
  200. HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, \
  201. (__ARMCC_VERSION % 1000000) / 10000, \
  202. (__ARMCC_VERSION % 10000) / 100)
  203. #endif
  204. #if defined(HEDLEY_ARM_VERSION_CHECK)
  205. #undef HEDLEY_ARM_VERSION_CHECK
  206. #endif
  207. #if defined(HEDLEY_ARM_VERSION)
  208. #define HEDLEY_ARM_VERSION_CHECK(major, minor, patch) \
  209. (HEDLEY_ARM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  210. #else
  211. #define HEDLEY_ARM_VERSION_CHECK(major, minor, patch) (0)
  212. #endif
  213. #if defined(HEDLEY_IBM_VERSION)
  214. #undef HEDLEY_IBM_VERSION
  215. #endif
  216. #if defined(__ibmxl__)
  217. #define HEDLEY_IBM_VERSION \
  218. HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, \
  219. __ibmxl_modification__)
  220. #elif defined(__xlC__) && defined(__xlC_ver__)
  221. #define HEDLEY_IBM_VERSION \
  222. HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, \
  223. (__xlC_ver__ >> 8) & 0xff)
  224. #elif defined(__xlC__)
  225. #define HEDLEY_IBM_VERSION \
  226. HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0)
  227. #endif
  228. #if defined(HEDLEY_IBM_VERSION_CHECK)
  229. #undef HEDLEY_IBM_VERSION_CHECK
  230. #endif
  231. #if defined(HEDLEY_IBM_VERSION)
  232. #define HEDLEY_IBM_VERSION_CHECK(major, minor, patch) \
  233. (HEDLEY_IBM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  234. #else
  235. #define HEDLEY_IBM_VERSION_CHECK(major, minor, patch) (0)
  236. #endif
  237. #if defined(HEDLEY_TI_VERSION)
  238. #undef HEDLEY_TI_VERSION
  239. #endif
  240. #if defined(__TI_COMPILER_VERSION__) && \
  241. (defined(__TMS470__) || defined(__TI_ARM__) || defined(__MSP430__) || \
  242. defined(__TMS320C2000__))
  243. #if (__TI_COMPILER_VERSION__ >= 16000000)
  244. #define HEDLEY_TI_VERSION \
  245. HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, \
  246. (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
  247. (__TI_COMPILER_VERSION__ % 1000))
  248. #endif
  249. #endif
  250. #if defined(HEDLEY_TI_VERSION_CHECK)
  251. #undef HEDLEY_TI_VERSION_CHECK
  252. #endif
  253. #if defined(HEDLEY_TI_VERSION)
  254. #define HEDLEY_TI_VERSION_CHECK(major, minor, patch) \
  255. (HEDLEY_TI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  256. #else
  257. #define HEDLEY_TI_VERSION_CHECK(major, minor, patch) (0)
  258. #endif
  259. #if defined(HEDLEY_TI_CL2000_VERSION)
  260. #undef HEDLEY_TI_CL2000_VERSION
  261. #endif
  262. #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__)
  263. #define HEDLEY_TI_CL2000_VERSION \
  264. HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, \
  265. (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
  266. (__TI_COMPILER_VERSION__ % 1000))
  267. #endif
  268. #if defined(HEDLEY_TI_CL2000_VERSION_CHECK)
  269. #undef HEDLEY_TI_CL2000_VERSION_CHECK
  270. #endif
  271. #if defined(HEDLEY_TI_CL2000_VERSION)
  272. #define HEDLEY_TI_CL2000_VERSION_CHECK(major, minor, patch) \
  273. (HEDLEY_TI_CL2000_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  274. #else
  275. #define HEDLEY_TI_CL2000_VERSION_CHECK(major, minor, patch) (0)
  276. #endif
  277. #if defined(HEDLEY_TI_CL430_VERSION)
  278. #undef HEDLEY_TI_CL430_VERSION
  279. #endif
  280. #if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__)
  281. #define HEDLEY_TI_CL430_VERSION \
  282. HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, \
  283. (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
  284. (__TI_COMPILER_VERSION__ % 1000))
  285. #endif
  286. #if defined(HEDLEY_TI_CL430_VERSION_CHECK)
  287. #undef HEDLEY_TI_CL430_VERSION_CHECK
  288. #endif
  289. #if defined(HEDLEY_TI_CL430_VERSION)
  290. #define HEDLEY_TI_CL430_VERSION_CHECK(major, minor, patch) \
  291. (HEDLEY_TI_CL430_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  292. #else
  293. #define HEDLEY_TI_CL430_VERSION_CHECK(major, minor, patch) (0)
  294. #endif
  295. #if defined(HEDLEY_TI_ARMCL_VERSION)
  296. #undef HEDLEY_TI_ARMCL_VERSION
  297. #endif
  298. #if defined(__TI_COMPILER_VERSION__) && \
  299. (defined(__TMS470__) || defined(__TI_ARM__))
  300. #define HEDLEY_TI_ARMCL_VERSION \
  301. HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, \
  302. (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
  303. (__TI_COMPILER_VERSION__ % 1000))
  304. #endif
  305. #if defined(HEDLEY_TI_ARMCL_VERSION_CHECK)
  306. #undef HEDLEY_TI_ARMCL_VERSION_CHECK
  307. #endif
  308. #if defined(HEDLEY_TI_ARMCL_VERSION)
  309. #define HEDLEY_TI_ARMCL_VERSION_CHECK(major, minor, patch) \
  310. (HEDLEY_TI_ARMCL_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  311. #else
  312. #define HEDLEY_TI_ARMCL_VERSION_CHECK(major, minor, patch) (0)
  313. #endif
  314. #if defined(HEDLEY_TI_CL6X_VERSION)
  315. #undef HEDLEY_TI_CL6X_VERSION
  316. #endif
  317. #if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__)
  318. #define HEDLEY_TI_CL6X_VERSION \
  319. HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, \
  320. (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
  321. (__TI_COMPILER_VERSION__ % 1000))
  322. #endif
  323. #if defined(HEDLEY_TI_CL6X_VERSION_CHECK)
  324. #undef HEDLEY_TI_CL6X_VERSION_CHECK
  325. #endif
  326. #if defined(HEDLEY_TI_CL6X_VERSION)
  327. #define HEDLEY_TI_CL6X_VERSION_CHECK(major, minor, patch) \
  328. (HEDLEY_TI_CL6X_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  329. #else
  330. #define HEDLEY_TI_CL6X_VERSION_CHECK(major, minor, patch) (0)
  331. #endif
  332. #if defined(HEDLEY_TI_CL7X_VERSION)
  333. #undef HEDLEY_TI_CL7X_VERSION
  334. #endif
  335. #if defined(__TI_COMPILER_VERSION__) && defined(__C7000__)
  336. #define HEDLEY_TI_CL7X_VERSION \
  337. HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, \
  338. (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
  339. (__TI_COMPILER_VERSION__ % 1000))
  340. #endif
  341. #if defined(HEDLEY_TI_CL7X_VERSION_CHECK)
  342. #undef HEDLEY_TI_CL7X_VERSION_CHECK
  343. #endif
  344. #if defined(HEDLEY_TI_CL7X_VERSION)
  345. #define HEDLEY_TI_CL7X_VERSION_CHECK(major, minor, patch) \
  346. (HEDLEY_TI_CL7X_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  347. #else
  348. #define HEDLEY_TI_CL7X_VERSION_CHECK(major, minor, patch) (0)
  349. #endif
  350. #if defined(HEDLEY_TI_CLPRU_VERSION)
  351. #undef HEDLEY_TI_CLPRU_VERSION
  352. #endif
  353. #if defined(__TI_COMPILER_VERSION__) && defined(__PRU__)
  354. #define HEDLEY_TI_CLPRU_VERSION \
  355. HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, \
  356. (__TI_COMPILER_VERSION__ % 1000000) / 1000, \
  357. (__TI_COMPILER_VERSION__ % 1000))
  358. #endif
  359. #if defined(HEDLEY_TI_CLPRU_VERSION_CHECK)
  360. #undef HEDLEY_TI_CLPRU_VERSION_CHECK
  361. #endif
  362. #if defined(HEDLEY_TI_CLPRU_VERSION)
  363. #define HEDLEY_TI_CLPRU_VERSION_CHECK(major, minor, patch) \
  364. (HEDLEY_TI_CLPRU_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  365. #else
  366. #define HEDLEY_TI_CLPRU_VERSION_CHECK(major, minor, patch) (0)
  367. #endif
  368. #if defined(HEDLEY_CRAY_VERSION)
  369. #undef HEDLEY_CRAY_VERSION
  370. #endif
  371. #if defined(_CRAYC)
  372. #if defined(_RELEASE_PATCHLEVEL)
  373. #define HEDLEY_CRAY_VERSION \
  374. HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, \
  375. _RELEASE_PATCHLEVEL)
  376. #else
  377. #define HEDLEY_CRAY_VERSION \
  378. HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0)
  379. #endif
  380. #endif
  381. #if defined(HEDLEY_CRAY_VERSION_CHECK)
  382. #undef HEDLEY_CRAY_VERSION_CHECK
  383. #endif
  384. #if defined(HEDLEY_CRAY_VERSION)
  385. #define HEDLEY_CRAY_VERSION_CHECK(major, minor, patch) \
  386. (HEDLEY_CRAY_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  387. #else
  388. #define HEDLEY_CRAY_VERSION_CHECK(major, minor, patch) (0)
  389. #endif
  390. #if defined(HEDLEY_IAR_VERSION)
  391. #undef HEDLEY_IAR_VERSION
  392. #endif
  393. #if defined(__IAR_SYSTEMS_ICC__)
  394. #if __VER__ > 1000
  395. #define HEDLEY_IAR_VERSION \
  396. HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), \
  397. (__VER__ % 1000))
  398. #else
  399. #define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0)
  400. #endif
  401. #endif
  402. #if defined(HEDLEY_IAR_VERSION_CHECK)
  403. #undef HEDLEY_IAR_VERSION_CHECK
  404. #endif
  405. #if defined(HEDLEY_IAR_VERSION)
  406. #define HEDLEY_IAR_VERSION_CHECK(major, minor, patch) \
  407. (HEDLEY_IAR_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  408. #else
  409. #define HEDLEY_IAR_VERSION_CHECK(major, minor, patch) (0)
  410. #endif
  411. #if defined(HEDLEY_TINYC_VERSION)
  412. #undef HEDLEY_TINYC_VERSION
  413. #endif
  414. #if defined(__TINYC__)
  415. #define HEDLEY_TINYC_VERSION \
  416. HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, \
  417. __TINYC__ % 100)
  418. #endif
  419. #if defined(HEDLEY_TINYC_VERSION_CHECK)
  420. #undef HEDLEY_TINYC_VERSION_CHECK
  421. #endif
  422. #if defined(HEDLEY_TINYC_VERSION)
  423. #define HEDLEY_TINYC_VERSION_CHECK(major, minor, patch) \
  424. (HEDLEY_TINYC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  425. #else
  426. #define HEDLEY_TINYC_VERSION_CHECK(major, minor, patch) (0)
  427. #endif
  428. #if defined(HEDLEY_DMC_VERSION)
  429. #undef HEDLEY_DMC_VERSION
  430. #endif
  431. #if defined(__DMC__)
  432. #define HEDLEY_DMC_VERSION \
  433. HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf)
  434. #endif
  435. #if defined(HEDLEY_DMC_VERSION_CHECK)
  436. #undef HEDLEY_DMC_VERSION_CHECK
  437. #endif
  438. #if defined(HEDLEY_DMC_VERSION)
  439. #define HEDLEY_DMC_VERSION_CHECK(major, minor, patch) \
  440. (HEDLEY_DMC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  441. #else
  442. #define HEDLEY_DMC_VERSION_CHECK(major, minor, patch) (0)
  443. #endif
  444. #if defined(HEDLEY_COMPCERT_VERSION)
  445. #undef HEDLEY_COMPCERT_VERSION
  446. #endif
  447. #if defined(__COMPCERT_VERSION__)
  448. #define HEDLEY_COMPCERT_VERSION \
  449. HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, \
  450. (__COMPCERT_VERSION__ / 100) % 100, \
  451. __COMPCERT_VERSION__ % 100)
  452. #endif
  453. #if defined(HEDLEY_COMPCERT_VERSION_CHECK)
  454. #undef HEDLEY_COMPCERT_VERSION_CHECK
  455. #endif
  456. #if defined(HEDLEY_COMPCERT_VERSION)
  457. #define HEDLEY_COMPCERT_VERSION_CHECK(major, minor, patch) \
  458. (HEDLEY_COMPCERT_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  459. #else
  460. #define HEDLEY_COMPCERT_VERSION_CHECK(major, minor, patch) (0)
  461. #endif
  462. #if defined(HEDLEY_PELLES_VERSION)
  463. #undef HEDLEY_PELLES_VERSION
  464. #endif
  465. #if defined(__POCC__)
  466. #define HEDLEY_PELLES_VERSION \
  467. HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0)
  468. #endif
  469. #if defined(HEDLEY_PELLES_VERSION_CHECK)
  470. #undef HEDLEY_PELLES_VERSION_CHECK
  471. #endif
  472. #if defined(HEDLEY_PELLES_VERSION)
  473. #define HEDLEY_PELLES_VERSION_CHECK(major, minor, patch) \
  474. (HEDLEY_PELLES_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  475. #else
  476. #define HEDLEY_PELLES_VERSION_CHECK(major, minor, patch) (0)
  477. #endif
  478. #if defined(HEDLEY_GCC_VERSION)
  479. #undef HEDLEY_GCC_VERSION
  480. #endif
  481. #if defined(HEDLEY_GNUC_VERSION) && !defined(__clang__) && \
  482. !defined(HEDLEY_INTEL_VERSION) && !defined(HEDLEY_PGI_VERSION) && \
  483. !defined(HEDLEY_ARM_VERSION) && !defined(HEDLEY_TI_VERSION) && \
  484. !defined(HEDLEY_TI_ARMCL_VERSION) && \
  485. !defined(HEDLEY_TI_CL430_VERSION) && \
  486. !defined(HEDLEY_TI_CL2000_VERSION) && \
  487. !defined(HEDLEY_TI_CL6X_VERSION) && \
  488. !defined(HEDLEY_TI_CL7X_VERSION) && \
  489. !defined(HEDLEY_TI_CLPRU_VERSION) && !defined(__COMPCERT__)
  490. #define HEDLEY_GCC_VERSION HEDLEY_GNUC_VERSION
  491. #endif
  492. #if defined(HEDLEY_GCC_VERSION_CHECK)
  493. #undef HEDLEY_GCC_VERSION_CHECK
  494. #endif
  495. #if defined(HEDLEY_GCC_VERSION)
  496. #define HEDLEY_GCC_VERSION_CHECK(major, minor, patch) \
  497. (HEDLEY_GCC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch))
  498. #else
  499. #define HEDLEY_GCC_VERSION_CHECK(major, minor, patch) (0)
  500. #endif
  501. #if defined(HEDLEY_HAS_ATTRIBUTE)
  502. #undef HEDLEY_HAS_ATTRIBUTE
  503. #endif
  504. #if defined(__has_attribute)
  505. #define HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute)
  506. #else
  507. #define HEDLEY_HAS_ATTRIBUTE(attribute) (0)
  508. #endif
  509. #if defined(HEDLEY_GNUC_HAS_ATTRIBUTE)
  510. #undef HEDLEY_GNUC_HAS_ATTRIBUTE
  511. #endif
  512. #if defined(__has_attribute)
  513. #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
  514. __has_attribute(attribute)
  515. #else
  516. #define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
  517. HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
  518. #endif
  519. #if defined(HEDLEY_GCC_HAS_ATTRIBUTE)
  520. #undef HEDLEY_GCC_HAS_ATTRIBUTE
  521. #endif
  522. #if defined(__has_attribute)
  523. #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
  524. __has_attribute(attribute)
  525. #else
  526. #define HEDLEY_GCC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
  527. HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
  528. #endif
  529. #if defined(HEDLEY_HAS_CPP_ATTRIBUTE)
  530. #undef HEDLEY_HAS_CPP_ATTRIBUTE
  531. #endif
  532. #if defined(__has_cpp_attribute) && defined(__cplusplus) && \
  533. (!defined(HEDLEY_SUNPRO_VERSION) || \
  534. HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0))
  535. #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute)
  536. #else
  537. #define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0)
  538. #endif
  539. #if defined(HEDLEY_HAS_CPP_ATTRIBUTE_NS)
  540. #undef HEDLEY_HAS_CPP_ATTRIBUTE_NS
  541. #endif
  542. #if !defined(__cplusplus) || !defined(__has_cpp_attribute)
  543. #define HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) (0)
  544. #elif !defined(HEDLEY_PGI_VERSION) && !defined(HEDLEY_IAR_VERSION) && \
  545. (!defined(HEDLEY_SUNPRO_VERSION) || \
  546. HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) && \
  547. (!defined(HEDLEY_MSVC_VERSION) || \
  548. HEDLEY_MSVC_VERSION_CHECK(19, 20, 0))
  549. #define HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) \
  550. HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute)
  551. #else
  552. #define HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns, attribute) (0)
  553. #endif
  554. #if defined(HEDLEY_GNUC_HAS_CPP_ATTRIBUTE)
  555. #undef HEDLEY_GNUC_HAS_CPP_ATTRIBUTE
  556. #endif
  557. #if defined(__has_cpp_attribute) && defined(__cplusplus)
  558. #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \
  559. __has_cpp_attribute(attribute)
  560. #else
  561. #define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \
  562. HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
  563. #endif
  564. #if defined(HEDLEY_GCC_HAS_CPP_ATTRIBUTE)
  565. #undef HEDLEY_GCC_HAS_CPP_ATTRIBUTE
  566. #endif
  567. #if defined(__has_cpp_attribute) && defined(__cplusplus)
  568. #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \
  569. __has_cpp_attribute(attribute)
  570. #else
  571. #define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \
  572. HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
  573. #endif
  574. #if defined(HEDLEY_HAS_BUILTIN)
  575. #undef HEDLEY_HAS_BUILTIN
  576. #endif
  577. #if defined(__has_builtin)
  578. #define HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin)
  579. #else
  580. #define HEDLEY_HAS_BUILTIN(builtin) (0)
  581. #endif
  582. #if defined(HEDLEY_GNUC_HAS_BUILTIN)
  583. #undef HEDLEY_GNUC_HAS_BUILTIN
  584. #endif
  585. #if defined(__has_builtin)
  586. #define HEDLEY_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \
  587. __has_builtin(builtin)
  588. #else
  589. #define HEDLEY_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \
  590. HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
  591. #endif
  592. #if defined(HEDLEY_GCC_HAS_BUILTIN)
  593. #undef HEDLEY_GCC_HAS_BUILTIN
  594. #endif
  595. #if defined(__has_builtin)
  596. #define HEDLEY_GCC_HAS_BUILTIN(builtin, major, minor, patch) \
  597. __has_builtin(builtin)
  598. #else
  599. #define HEDLEY_GCC_HAS_BUILTIN(builtin, major, minor, patch) \
  600. HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
  601. #endif
  602. #if defined(HEDLEY_HAS_FEATURE)
  603. #undef HEDLEY_HAS_FEATURE
  604. #endif
  605. #if defined(__has_feature)
  606. #define HEDLEY_HAS_FEATURE(feature) __has_feature(feature)
  607. #else
  608. #define HEDLEY_HAS_FEATURE(feature) (0)
  609. #endif
  610. #if defined(HEDLEY_GNUC_HAS_FEATURE)
  611. #undef HEDLEY_GNUC_HAS_FEATURE
  612. #endif
  613. #if defined(__has_feature)
  614. #define HEDLEY_GNUC_HAS_FEATURE(feature, major, minor, patch) \
  615. __has_feature(feature)
  616. #else
  617. #define HEDLEY_GNUC_HAS_FEATURE(feature, major, minor, patch) \
  618. HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
  619. #endif
  620. #if defined(HEDLEY_GCC_HAS_FEATURE)
  621. #undef HEDLEY_GCC_HAS_FEATURE
  622. #endif
  623. #if defined(__has_feature)
  624. #define HEDLEY_GCC_HAS_FEATURE(feature, major, minor, patch) \
  625. __has_feature(feature)
  626. #else
  627. #define HEDLEY_GCC_HAS_FEATURE(feature, major, minor, patch) \
  628. HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
  629. #endif
  630. #if defined(HEDLEY_HAS_EXTENSION)
  631. #undef HEDLEY_HAS_EXTENSION
  632. #endif
  633. #if defined(__has_extension)
  634. #define HEDLEY_HAS_EXTENSION(extension) __has_extension(extension)
  635. #else
  636. #define HEDLEY_HAS_EXTENSION(extension) (0)
  637. #endif
  638. #if defined(HEDLEY_GNUC_HAS_EXTENSION)
  639. #undef HEDLEY_GNUC_HAS_EXTENSION
  640. #endif
  641. #if defined(__has_extension)
  642. #define HEDLEY_GNUC_HAS_EXTENSION(extension, major, minor, patch) \
  643. __has_extension(extension)
  644. #else
  645. #define HEDLEY_GNUC_HAS_EXTENSION(extension, major, minor, patch) \
  646. HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
  647. #endif
  648. #if defined(HEDLEY_GCC_HAS_EXTENSION)
  649. #undef HEDLEY_GCC_HAS_EXTENSION
  650. #endif
  651. #if defined(__has_extension)
  652. #define HEDLEY_GCC_HAS_EXTENSION(extension, major, minor, patch) \
  653. __has_extension(extension)
  654. #else
  655. #define HEDLEY_GCC_HAS_EXTENSION(extension, major, minor, patch) \
  656. HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
  657. #endif
  658. #if defined(HEDLEY_HAS_DECLSPEC_ATTRIBUTE)
  659. #undef HEDLEY_HAS_DECLSPEC_ATTRIBUTE
  660. #endif
  661. #if defined(__has_declspec_attribute)
  662. #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) \
  663. __has_declspec_attribute(attribute)
  664. #else
  665. #define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0)
  666. #endif
  667. #if defined(HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE)
  668. #undef HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE
  669. #endif
  670. #if defined(__has_declspec_attribute)
  671. #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \
  672. __has_declspec_attribute(attribute)
  673. #else
  674. #define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \
  675. HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
  676. #endif
  677. #if defined(HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE)
  678. #undef HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE
  679. #endif
  680. #if defined(__has_declspec_attribute)
  681. #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \
  682. __has_declspec_attribute(attribute)
  683. #else
  684. #define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \
  685. HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
  686. #endif
  687. #if defined(HEDLEY_HAS_WARNING)
  688. #undef HEDLEY_HAS_WARNING
  689. #endif
  690. #if defined(__has_warning)
  691. #define HEDLEY_HAS_WARNING(warning) __has_warning(warning)
  692. #else
  693. #define HEDLEY_HAS_WARNING(warning) (0)
  694. #endif
  695. #if defined(HEDLEY_GNUC_HAS_WARNING)
  696. #undef HEDLEY_GNUC_HAS_WARNING
  697. #endif
  698. #if defined(__has_warning)
  699. #define HEDLEY_GNUC_HAS_WARNING(warning, major, minor, patch) \
  700. __has_warning(warning)
  701. #else
  702. #define HEDLEY_GNUC_HAS_WARNING(warning, major, minor, patch) \
  703. HEDLEY_GNUC_VERSION_CHECK(major, minor, patch)
  704. #endif
  705. #if defined(HEDLEY_GCC_HAS_WARNING)
  706. #undef HEDLEY_GCC_HAS_WARNING
  707. #endif
  708. #if defined(__has_warning)
  709. #define HEDLEY_GCC_HAS_WARNING(warning, major, minor, patch) \
  710. __has_warning(warning)
  711. #else
  712. #define HEDLEY_GCC_HAS_WARNING(warning, major, minor, patch) \
  713. HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
  714. #endif
  715. /* HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for
  716. HEDLEY INTERNAL USE ONLY. API subject to change without notice. */
  717. #if defined(HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
  718. #undef HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_
  719. #endif
  720. #if defined(__cplusplus)
  721. #if HEDLEY_HAS_WARNING("-Wc++98-compat")
  722. #if HEDLEY_HAS_WARNING("-Wc++17-extensions")
  723. #define HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
  724. HEDLEY_DIAGNOSTIC_PUSH \
  725. _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
  726. _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \
  727. xpr HEDLEY_DIAGNOSTIC_POP
  728. #else
  729. #define HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \
  730. HEDLEY_DIAGNOSTIC_PUSH \
  731. _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \
  732. xpr HEDLEY_DIAGNOSTIC_POP
  733. #endif
  734. #endif
  735. #endif
  736. #if !defined(HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_)
  737. #define HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x
  738. #endif
  739. #if defined(HEDLEY_CONST_CAST)
  740. #undef HEDLEY_CONST_CAST
  741. #endif
  742. #if defined(__cplusplus)
  743. #define HEDLEY_CONST_CAST(T, expr) (const_cast<T>(expr))
  744. #elif HEDLEY_HAS_WARNING("-Wcast-qual") || \
  745. HEDLEY_GCC_VERSION_CHECK(4, 6, 0) || \
  746. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  747. #define HEDLEY_CONST_CAST(T, expr) \
  748. (__extension__({ \
  749. HEDLEY_DIAGNOSTIC_PUSH \
  750. HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL((T)(expr)); \
  751. HEDLEY_DIAGNOSTIC_POP \
  752. }))
  753. #else
  754. #define HEDLEY_CONST_CAST(T, expr) ((T)(expr))
  755. #endif
  756. #if defined(HEDLEY_REINTERPRET_CAST)
  757. #undef HEDLEY_REINTERPRET_CAST
  758. #endif
  759. #if defined(__cplusplus)
  760. #define HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast<T>(expr))
  761. #else
  762. #define HEDLEY_REINTERPRET_CAST(T, expr) ((T)(expr))
  763. #endif
  764. #if defined(HEDLEY_STATIC_CAST)
  765. #undef HEDLEY_STATIC_CAST
  766. #endif
  767. #if defined(__cplusplus)
  768. #define HEDLEY_STATIC_CAST(T, expr) (static_cast<T>(expr))
  769. #else
  770. #define HEDLEY_STATIC_CAST(T, expr) ((T)(expr))
  771. #endif
  772. #if defined(HEDLEY_CPP_CAST)
  773. #undef HEDLEY_CPP_CAST
  774. #endif
  775. #if defined(__cplusplus)
  776. #if HEDLEY_HAS_WARNING("-Wold-style-cast")
  777. #define HEDLEY_CPP_CAST(T, expr) \
  778. HEDLEY_DIAGNOSTIC_PUSH \
  779. _Pragma("clang diagnostic ignored \"-Wold-style-cast\"")((T)(expr)) \
  780. HEDLEY_DIAGNOSTIC_POP
  781. #elif HEDLEY_IAR_VERSION_CHECK(8, 3, 0)
  782. #define HEDLEY_CPP_CAST(T, expr) \
  783. HEDLEY_DIAGNOSTIC_PUSH \
  784. _Pragma("diag_suppress=Pe137") HEDLEY_DIAGNOSTIC_POP #else
  785. #define HEDLEY_CPP_CAST(T, expr) ((T)(expr))
  786. #endif
  787. #else
  788. #define HEDLEY_CPP_CAST(T, expr) (expr)
  789. #endif
  790. #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
  791. defined(__clang__) || HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \
  792. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  793. HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || \
  794. HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \
  795. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  796. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  797. HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || \
  798. HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || \
  799. HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || \
  800. HEDLEY_TI_CL6X_VERSION_CHECK(7, 0, 0) || \
  801. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  802. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \
  803. HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) || \
  804. HEDLEY_TINYC_VERSION_CHECK(0, 9, 17) || \
  805. HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \
  806. (HEDLEY_IBM_VERSION_CHECK(10, 1, 0) && defined(__C99_PRAGMA_OPERATOR))
  807. #define HEDLEY_PRAGMA(value) _Pragma(#value)
  808. #elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
  809. #define HEDLEY_PRAGMA(value) __pragma(value)
  810. #else
  811. #define HEDLEY_PRAGMA(value)
  812. #endif
  813. #if defined(HEDLEY_DIAGNOSTIC_PUSH)
  814. #undef HEDLEY_DIAGNOSTIC_PUSH
  815. #endif
  816. #if defined(HEDLEY_DIAGNOSTIC_POP)
  817. #undef HEDLEY_DIAGNOSTIC_POP
  818. #endif
  819. #if defined(__clang__)
  820. #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
  821. #define HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
  822. #elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  823. #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
  824. #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
  825. #elif HEDLEY_GCC_VERSION_CHECK(4, 6, 0)
  826. #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
  827. #define HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
  828. #elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
  829. #define HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push))
  830. #define HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop))
  831. #elif HEDLEY_ARM_VERSION_CHECK(5, 6, 0)
  832. #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("push")
  833. #define HEDLEY_DIAGNOSTIC_POP _Pragma("pop")
  834. #elif HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  835. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  836. HEDLEY_TI_CL430_VERSION_CHECK(4, 4, 0) || \
  837. HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || \
  838. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  839. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
  840. #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push")
  841. #define HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop")
  842. #elif HEDLEY_PELLES_VERSION_CHECK(2, 90, 0)
  843. #define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)")
  844. #define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)")
  845. #else
  846. #define HEDLEY_DIAGNOSTIC_PUSH
  847. #define HEDLEY_DIAGNOSTIC_POP
  848. #endif
  849. #if defined(HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED)
  850. #undef HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
  851. #endif
  852. #if HEDLEY_HAS_WARNING("-Wdeprecated-declarations")
  853. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \
  854. _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
  855. #elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  856. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \
  857. _Pragma("warning(disable:1478 1786)")
  858. #elif HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
  859. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
  860. #elif HEDLEY_GCC_VERSION_CHECK(4, 3, 0)
  861. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \
  862. _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
  863. #elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
  864. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable : 4996))
  865. #elif HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  866. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  867. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  868. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  869. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  870. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  871. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  872. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  873. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  874. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  875. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  876. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  877. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  878. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  879. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
  880. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718")
  881. #elif HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && !defined(__cplusplus)
  882. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \
  883. _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)")
  884. #elif HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && defined(__cplusplus)
  885. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \
  886. _Pragma("error_messages(off,symdeprecated,symdeprecated2)")
  887. #elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
  888. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \
  889. _Pragma("diag_suppress=Pe1444,Pe1215")
  890. #elif HEDLEY_PELLES_VERSION_CHECK(2, 90, 0)
  891. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)")
  892. #else
  893. #define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED
  894. #endif
  895. #if defined(HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS)
  896. #undef HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
  897. #endif
  898. #if HEDLEY_HAS_WARNING("-Wunknown-pragmas")
  899. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
  900. _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"")
  901. #elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  902. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
  903. _Pragma("warning(disable:161)")
  904. #elif HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
  905. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675")
  906. #elif HEDLEY_GCC_VERSION_CHECK(4, 3, 0)
  907. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
  908. _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"")
  909. #elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
  910. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
  911. __pragma(warning(disable : 4068))
  912. #elif HEDLEY_TI_VERSION_CHECK(16, 9, 0) || \
  913. HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || \
  914. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  915. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0)
  916. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
  917. #elif HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0)
  918. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163")
  919. #elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
  920. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161")
  921. #else
  922. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS
  923. #endif
  924. #if defined(HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES)
  925. #undef HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
  926. #endif
  927. #if HEDLEY_HAS_WARNING("-Wunknown-attributes")
  928. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES \
  929. _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"")
  930. #elif HEDLEY_GCC_VERSION_CHECK(4, 6, 0)
  931. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES \
  932. _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
  933. #elif HEDLEY_INTEL_VERSION_CHECK(17, 0, 0)
  934. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES \
  935. _Pragma("warning(disable:1292)")
  936. #elif HEDLEY_MSVC_VERSION_CHECK(19, 0, 0)
  937. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES \
  938. __pragma(warning(disable : 5030))
  939. #elif HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
  940. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES \
  941. _Pragma("diag_suppress 1097")
  942. #elif HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)
  943. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES \
  944. _Pragma("error_messages(off,attrskipunsup)")
  945. #elif HEDLEY_TI_VERSION_CHECK(18, 1, 0) || \
  946. HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || \
  947. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0)
  948. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES \
  949. _Pragma("diag_suppress 1173")
  950. #elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
  951. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES \
  952. _Pragma("diag_suppress=Pe1097")
  953. #else
  954. #define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES
  955. #endif
  956. #if defined(HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL)
  957. #undef HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
  958. #endif
  959. #if HEDLEY_HAS_WARNING("-Wcast-qual")
  960. #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
  961. _Pragma("clang diagnostic ignored \"-Wcast-qual\"")
  962. #elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  963. #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
  964. _Pragma("warning(disable:2203 2331)")
  965. #elif HEDLEY_GCC_VERSION_CHECK(3, 0, 0)
  966. #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \
  967. _Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
  968. #else
  969. #define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL
  970. #endif
  971. #if defined(HEDLEY_DEPRECATED)
  972. #undef HEDLEY_DEPRECATED
  973. #endif
  974. #if defined(HEDLEY_DEPRECATED_FOR)
  975. #undef HEDLEY_DEPRECATED_FOR
  976. #endif
  977. #if defined(__cplusplus) && (__cplusplus >= 201402L)
  978. #define HEDLEY_DEPRECATED(since) \
  979. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_( \
  980. [[deprecated("Since " #since)]])
  981. #define HEDLEY_DEPRECATED_FOR(since, replacement) \
  982. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_( \
  983. [[deprecated("Since " #since "; use " #replacement)]])
  984. #elif HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \
  985. HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \
  986. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  987. HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || \
  988. HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) || \
  989. HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \
  990. HEDLEY_TI_VERSION_CHECK(18, 1, 0) || \
  991. HEDLEY_TI_ARMCL_VERSION_CHECK(18, 1, 0) || \
  992. HEDLEY_TI_CL6X_VERSION_CHECK(8, 3, 0) || \
  993. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  994. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 3, 0)
  995. #define HEDLEY_DEPRECATED(since) \
  996. __attribute__((__deprecated__("Since " #since)))
  997. #define HEDLEY_DEPRECATED_FOR(since, replacement) \
  998. __attribute__((__deprecated__("Since " #since "; use " #replacement)))
  999. #elif HEDLEY_HAS_ATTRIBUTE(deprecated) || HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \
  1000. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1001. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1002. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  1003. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1004. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1005. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  1006. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1007. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1008. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  1009. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1010. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1011. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1012. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1013. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  1014. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1015. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
  1016. #define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__))
  1017. #define HEDLEY_DEPRECATED_FOR(since, replacement) \
  1018. __attribute__((__deprecated__))
  1019. #elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0)
  1020. #define HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " #since))
  1021. #define HEDLEY_DEPRECATED_FOR(since, replacement) \
  1022. __declspec(deprecated("Since " #since "; use " #replacement))
  1023. #elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \
  1024. HEDLEY_PELLES_VERSION_CHECK(6, 50, 0)
  1025. #define HEDLEY_DEPRECATED(since) __declspec(deprecated)
  1026. #define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated)
  1027. #elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
  1028. #define HEDLEY_DEPRECATED(since) _Pragma("deprecated")
  1029. #define HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated")
  1030. #else
  1031. #define HEDLEY_DEPRECATED(since)
  1032. #define HEDLEY_DEPRECATED_FOR(since, replacement)
  1033. #endif
  1034. #if defined(HEDLEY_UNAVAILABLE)
  1035. #undef HEDLEY_UNAVAILABLE
  1036. #endif
  1037. #if HEDLEY_HAS_ATTRIBUTE(warning) || HEDLEY_GCC_VERSION_CHECK(4, 3, 0) || \
  1038. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  1039. #define HEDLEY_UNAVAILABLE(available_since) \
  1040. __attribute__((__warning__("Not available until " #available_since)))
  1041. #else
  1042. #define HEDLEY_UNAVAILABLE(available_since)
  1043. #endif
  1044. #if defined(HEDLEY_WARN_UNUSED_RESULT)
  1045. #undef HEDLEY_WARN_UNUSED_RESULT
  1046. #endif
  1047. #if defined(HEDLEY_WARN_UNUSED_RESULT_MSG)
  1048. #undef HEDLEY_WARN_UNUSED_RESULT_MSG
  1049. #endif
  1050. #if (HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L)
  1051. #define HEDLEY_WARN_UNUSED_RESULT \
  1052. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
  1053. #define HEDLEY_WARN_UNUSED_RESULT_MSG(msg) \
  1054. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]])
  1055. #elif HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard)
  1056. #define HEDLEY_WARN_UNUSED_RESULT \
  1057. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
  1058. #define HEDLEY_WARN_UNUSED_RESULT_MSG(msg) \
  1059. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]])
  1060. #elif HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \
  1061. HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \
  1062. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1063. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1064. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  1065. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1066. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1067. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  1068. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1069. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1070. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  1071. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1072. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1073. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1074. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1075. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  1076. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1077. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \
  1078. (HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \
  1079. HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
  1080. #define HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
  1081. #define HEDLEY_WARN_UNUSED_RESULT_MSG(msg) \
  1082. __attribute__((__warn_unused_result__))
  1083. #elif defined(_Check_return_) /* SAL */
  1084. #define HEDLEY_WARN_UNUSED_RESULT _Check_return_
  1085. #define HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_
  1086. #else
  1087. #define HEDLEY_WARN_UNUSED_RESULT
  1088. #define HEDLEY_WARN_UNUSED_RESULT_MSG(msg)
  1089. #endif
  1090. #if defined(HEDLEY_SENTINEL)
  1091. #undef HEDLEY_SENTINEL
  1092. #endif
  1093. #if HEDLEY_HAS_ATTRIBUTE(sentinel) || HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \
  1094. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1095. HEDLEY_ARM_VERSION_CHECK(5, 4, 0)
  1096. #define HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position)))
  1097. #else
  1098. #define HEDLEY_SENTINEL(position)
  1099. #endif
  1100. #if defined(HEDLEY_NO_RETURN)
  1101. #undef HEDLEY_NO_RETURN
  1102. #endif
  1103. #if HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
  1104. #define HEDLEY_NO_RETURN __noreturn
  1105. #elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  1106. #define HEDLEY_NO_RETURN __attribute__((__noreturn__))
  1107. #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
  1108. #define HEDLEY_NO_RETURN _Noreturn
  1109. #elif defined(__cplusplus) && (__cplusplus >= 201103L)
  1110. #define HEDLEY_NO_RETURN \
  1111. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]])
  1112. #elif HEDLEY_HAS_ATTRIBUTE(noreturn) || HEDLEY_GCC_VERSION_CHECK(3, 2, 0) || \
  1113. HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \
  1114. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1115. HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \
  1116. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1117. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  1118. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1119. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1120. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  1121. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1122. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1123. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  1124. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1125. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1126. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1127. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1128. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  1129. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1130. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
  1131. #define HEDLEY_NO_RETURN __attribute__((__noreturn__))
  1132. #elif HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
  1133. #define HEDLEY_NO_RETURN _Pragma("does_not_return")
  1134. #elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0)
  1135. #define HEDLEY_NO_RETURN __declspec(noreturn)
  1136. #elif HEDLEY_TI_CL6X_VERSION_CHECK(6, 0, 0) && defined(__cplusplus)
  1137. #define HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;")
  1138. #elif HEDLEY_COMPCERT_VERSION_CHECK(3, 2, 0)
  1139. #define HEDLEY_NO_RETURN __attribute((noreturn))
  1140. #elif HEDLEY_PELLES_VERSION_CHECK(9, 0, 0)
  1141. #define HEDLEY_NO_RETURN __declspec(noreturn)
  1142. #else
  1143. #define HEDLEY_NO_RETURN
  1144. #endif
  1145. #if defined(HEDLEY_NO_ESCAPE)
  1146. #undef HEDLEY_NO_ESCAPE
  1147. #endif
  1148. #if HEDLEY_HAS_ATTRIBUTE(noescape)
  1149. #define HEDLEY_NO_ESCAPE __attribute__((__noescape__))
  1150. #else
  1151. #define HEDLEY_NO_ESCAPE
  1152. #endif
  1153. #if defined(HEDLEY_UNREACHABLE)
  1154. #undef HEDLEY_UNREACHABLE
  1155. #endif
  1156. #if defined(HEDLEY_UNREACHABLE_RETURN)
  1157. #undef HEDLEY_UNREACHABLE_RETURN
  1158. #endif
  1159. #if defined(HEDLEY_ASSUME)
  1160. #undef HEDLEY_ASSUME
  1161. #endif
  1162. #if HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  1163. #define HEDLEY_ASSUME(expr) __assume(expr)
  1164. #elif HEDLEY_HAS_BUILTIN(__builtin_assume)
  1165. #define HEDLEY_ASSUME(expr) __builtin_assume(expr)
  1166. #elif HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \
  1167. HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0)
  1168. #if defined(__cplusplus)
  1169. #define HEDLEY_ASSUME(expr) std::_nassert(expr)
  1170. #else
  1171. #define HEDLEY_ASSUME(expr) _nassert(expr)
  1172. #endif
  1173. #endif
  1174. #if (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && \
  1175. (!defined(HEDLEY_ARM_VERSION))) || \
  1176. HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \
  1177. HEDLEY_PGI_VERSION_CHECK(18, 10, 0) || \
  1178. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1179. HEDLEY_IBM_VERSION_CHECK(13, 1, 5)
  1180. #define HEDLEY_UNREACHABLE() __builtin_unreachable()
  1181. #elif defined(HEDLEY_ASSUME)
  1182. #define HEDLEY_UNREACHABLE() HEDLEY_ASSUME(0)
  1183. #endif
  1184. #if !defined(HEDLEY_ASSUME)
  1185. #if defined(HEDLEY_UNREACHABLE)
  1186. #define HEDLEY_ASSUME(expr) \
  1187. HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (HEDLEY_UNREACHABLE(), 1)))
  1188. #else
  1189. #define HEDLEY_ASSUME(expr) HEDLEY_STATIC_CAST(void, expr)
  1190. #endif
  1191. #endif
  1192. #if defined(HEDLEY_UNREACHABLE)
  1193. #if HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \
  1194. HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0)
  1195. #define HEDLEY_UNREACHABLE_RETURN(value) \
  1196. return (HEDLEY_STATIC_CAST(void, HEDLEY_ASSUME(0)), (value))
  1197. #else
  1198. #define HEDLEY_UNREACHABLE_RETURN(value) HEDLEY_UNREACHABLE()
  1199. #endif
  1200. #else
  1201. #define HEDLEY_UNREACHABLE_RETURN(value) return (value)
  1202. #endif
  1203. #if !defined(HEDLEY_UNREACHABLE)
  1204. #define HEDLEY_UNREACHABLE() HEDLEY_ASSUME(0)
  1205. #endif
  1206. HEDLEY_DIAGNOSTIC_PUSH
  1207. #if HEDLEY_HAS_WARNING("-Wpedantic")
  1208. #pragma clang diagnostic ignored "-Wpedantic"
  1209. #endif
  1210. #if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus)
  1211. #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
  1212. #endif
  1213. #if HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros", 4, 0, 0)
  1214. #if defined(__clang__)
  1215. #pragma clang diagnostic ignored "-Wvariadic-macros"
  1216. #elif defined(HEDLEY_GCC_VERSION)
  1217. #pragma GCC diagnostic ignored "-Wvariadic-macros"
  1218. #endif
  1219. #endif
  1220. #if defined(HEDLEY_NON_NULL)
  1221. #undef HEDLEY_NON_NULL
  1222. #endif
  1223. #if HEDLEY_HAS_ATTRIBUTE(nonnull) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \
  1224. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1225. HEDLEY_ARM_VERSION_CHECK(4, 1, 0)
  1226. #define HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
  1227. #else
  1228. #define HEDLEY_NON_NULL(...)
  1229. #endif
  1230. HEDLEY_DIAGNOSTIC_POP
  1231. #if defined(HEDLEY_PRINTF_FORMAT)
  1232. #undef HEDLEY_PRINTF_FORMAT
  1233. #endif
  1234. #if defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format, 4, 4, 0) && \
  1235. !defined(__USE_MINGW_ANSI_STDIO)
  1236. #define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \
  1237. __attribute__((__format__(ms_printf, string_idx, first_to_check)))
  1238. #elif defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format, 4, 4, 0) && \
  1239. defined(__USE_MINGW_ANSI_STDIO)
  1240. #define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \
  1241. __attribute__((__format__(gnu_printf, string_idx, first_to_check)))
  1242. #elif HEDLEY_HAS_ATTRIBUTE(format) || HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \
  1243. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1244. HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || \
  1245. HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \
  1246. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1247. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  1248. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1249. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1250. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  1251. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1252. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1253. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  1254. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1255. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1256. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1257. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1258. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  1259. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1260. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
  1261. #define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \
  1262. __attribute__((__format__(__printf__, string_idx, first_to_check)))
  1263. #elif HEDLEY_PELLES_VERSION_CHECK(6, 0, 0)
  1264. #define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \
  1265. __declspec(vaformat(printf, string_idx, first_to_check))
  1266. #else
  1267. #define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check)
  1268. #endif
  1269. #if defined(HEDLEY_CONSTEXPR)
  1270. #undef HEDLEY_CONSTEXPR
  1271. #endif
  1272. #if defined(__cplusplus)
  1273. #if __cplusplus >= 201103L
  1274. #define HEDLEY_CONSTEXPR HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr)
  1275. #endif
  1276. #endif
  1277. #if !defined(HEDLEY_CONSTEXPR)
  1278. #define HEDLEY_CONSTEXPR
  1279. #endif
  1280. #if defined(HEDLEY_PREDICT)
  1281. #undef HEDLEY_PREDICT
  1282. #endif
  1283. #if defined(HEDLEY_LIKELY)
  1284. #undef HEDLEY_LIKELY
  1285. #endif
  1286. #if defined(HEDLEY_UNLIKELY)
  1287. #undef HEDLEY_UNLIKELY
  1288. #endif
  1289. #if defined(HEDLEY_UNPREDICTABLE)
  1290. #undef HEDLEY_UNPREDICTABLE
  1291. #endif
  1292. #if HEDLEY_HAS_BUILTIN(__builtin_unpredictable)
  1293. #define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
  1294. #endif
  1295. #if HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \
  1296. HEDLEY_GCC_VERSION_CHECK(9, 0, 0)
  1297. #define HEDLEY_PREDICT(expr, value, probability) \
  1298. __builtin_expect_with_probability((expr), (value), (probability))
  1299. #define HEDLEY_PREDICT_TRUE(expr, probability) \
  1300. __builtin_expect_with_probability(!!(expr), 1, (probability))
  1301. #define HEDLEY_PREDICT_FALSE(expr, probability) \
  1302. __builtin_expect_with_probability(!!(expr), 0, (probability))
  1303. #define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
  1304. #define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
  1305. #elif HEDLEY_HAS_BUILTIN(__builtin_expect) || \
  1306. HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \
  1307. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1308. (HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \
  1309. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1310. HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \
  1311. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1312. HEDLEY_TI_ARMCL_VERSION_CHECK(4, 7, 0) || \
  1313. HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || \
  1314. HEDLEY_TI_CL2000_VERSION_CHECK(6, 1, 0) || \
  1315. HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \
  1316. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1317. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \
  1318. HEDLEY_TINYC_VERSION_CHECK(0, 9, 27) || \
  1319. HEDLEY_CRAY_VERSION_CHECK(8, 1, 0)
  1320. #define HEDLEY_PREDICT(expr, expected, probability) \
  1321. (((probability) >= 0.9) \
  1322. ? __builtin_expect((expr), (expected)) \
  1323. : (HEDLEY_STATIC_CAST(void, expected), (expr)))
  1324. #define HEDLEY_PREDICT_TRUE(expr, probability) \
  1325. (__extension__({ \
  1326. double hedley_probability_ = (probability); \
  1327. ((hedley_probability_ >= 0.9) \
  1328. ? __builtin_expect(!!(expr), 1) \
  1329. : ((hedley_probability_ <= 0.1) \
  1330. ? __builtin_expect(!!(expr), 0) \
  1331. : !!(expr))); \
  1332. }))
  1333. #define HEDLEY_PREDICT_FALSE(expr, probability) \
  1334. (__extension__({ \
  1335. double hedley_probability_ = (probability); \
  1336. ((hedley_probability_ >= 0.9) \
  1337. ? __builtin_expect(!!(expr), 0) \
  1338. : ((hedley_probability_ <= 0.1) \
  1339. ? __builtin_expect(!!(expr), 1) \
  1340. : !!(expr))); \
  1341. }))
  1342. #define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1)
  1343. #define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0)
  1344. #else
  1345. #define HEDLEY_PREDICT(expr, expected, probability) \
  1346. (HEDLEY_STATIC_CAST(void, expected), (expr))
  1347. #define HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr))
  1348. #define HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr))
  1349. #define HEDLEY_LIKELY(expr) (!!(expr))
  1350. #define HEDLEY_UNLIKELY(expr) (!!(expr))
  1351. #endif
  1352. #if !defined(HEDLEY_UNPREDICTABLE)
  1353. #define HEDLEY_UNPREDICTABLE(expr) HEDLEY_PREDICT(expr, 1, 0.5)
  1354. #endif
  1355. #if defined(HEDLEY_MALLOC)
  1356. #undef HEDLEY_MALLOC
  1357. #endif
  1358. #if HEDLEY_HAS_ATTRIBUTE(malloc) || HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \
  1359. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1360. HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \
  1361. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1362. HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \
  1363. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1364. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  1365. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1366. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1367. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  1368. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1369. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1370. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  1371. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1372. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1373. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1374. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1375. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  1376. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1377. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
  1378. #define HEDLEY_MALLOC __attribute__((__malloc__))
  1379. #elif HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
  1380. #define HEDLEY_MALLOC _Pragma("returns_new_memory")
  1381. #elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0)
  1382. #define HEDLEY_MALLOC __declspec(restrict)
  1383. #else
  1384. #define HEDLEY_MALLOC
  1385. #endif
  1386. #if defined(HEDLEY_PURE)
  1387. #undef HEDLEY_PURE
  1388. #endif
  1389. #if HEDLEY_HAS_ATTRIBUTE(pure) || HEDLEY_GCC_VERSION_CHECK(2, 96, 0) || \
  1390. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1391. HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \
  1392. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1393. HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \
  1394. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1395. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  1396. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1397. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1398. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  1399. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1400. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1401. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  1402. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1403. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1404. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1405. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1406. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  1407. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1408. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \
  1409. HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
  1410. #define HEDLEY_PURE __attribute__((__pure__))
  1411. #elif HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
  1412. #define HEDLEY_PURE _Pragma("does_not_write_global_data")
  1413. #elif defined(__cplusplus) && (HEDLEY_TI_CL430_VERSION_CHECK(2, 0, 1) || \
  1414. HEDLEY_TI_CL6X_VERSION_CHECK(4, 0, 0) || \
  1415. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0))
  1416. #define HEDLEY_PURE _Pragma("FUNC_IS_PURE;")
  1417. #else
  1418. #define HEDLEY_PURE
  1419. #endif
  1420. #if defined(HEDLEY_CONST)
  1421. #undef HEDLEY_CONST
  1422. #endif
  1423. #if HEDLEY_HAS_ATTRIBUTE(const) || HEDLEY_GCC_VERSION_CHECK(2, 5, 0) || \
  1424. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1425. HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \
  1426. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1427. HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \
  1428. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1429. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  1430. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1431. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1432. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  1433. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1434. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1435. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  1436. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1437. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1438. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1439. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1440. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  1441. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1442. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0) || \
  1443. HEDLEY_PGI_VERSION_CHECK(17, 10, 0)
  1444. #define HEDLEY_CONST __attribute__((__const__))
  1445. #elif HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0)
  1446. #define HEDLEY_CONST _Pragma("no_side_effect")
  1447. #else
  1448. #define HEDLEY_CONST HEDLEY_PURE
  1449. #endif
  1450. #if defined(HEDLEY_RESTRICT)
  1451. #undef HEDLEY_RESTRICT
  1452. #endif
  1453. #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
  1454. !defined(__cplusplus)
  1455. #define HEDLEY_RESTRICT restrict
  1456. #elif HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \
  1457. HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \
  1458. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1459. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1460. HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \
  1461. HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \
  1462. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1463. HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 4) || \
  1464. HEDLEY_TI_CL6X_VERSION_CHECK(8, 1, 0) || \
  1465. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1466. (HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)) || \
  1467. HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || defined(__clang__)
  1468. #define HEDLEY_RESTRICT __restrict
  1469. #elif HEDLEY_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus)
  1470. #define HEDLEY_RESTRICT _Restrict
  1471. #else
  1472. #define HEDLEY_RESTRICT
  1473. #endif
  1474. #if defined(HEDLEY_INLINE)
  1475. #undef HEDLEY_INLINE
  1476. #endif
  1477. #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
  1478. (defined(__cplusplus) && (__cplusplus >= 199711L))
  1479. #define HEDLEY_INLINE inline
  1480. #elif defined(HEDLEY_GCC_VERSION) || HEDLEY_ARM_VERSION_CHECK(6, 2, 0)
  1481. #define HEDLEY_INLINE __inline__
  1482. #elif HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || \
  1483. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1484. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 1, 0) || \
  1485. HEDLEY_TI_CL430_VERSION_CHECK(3, 1, 0) || \
  1486. HEDLEY_TI_CL2000_VERSION_CHECK(6, 2, 0) || \
  1487. HEDLEY_TI_CL6X_VERSION_CHECK(8, 0, 0) || \
  1488. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1489. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
  1490. #define HEDLEY_INLINE __inline
  1491. #else
  1492. #define HEDLEY_INLINE
  1493. #endif
  1494. #if defined(HEDLEY_ALWAYS_INLINE)
  1495. #undef HEDLEY_ALWAYS_INLINE
  1496. #endif
  1497. #if HEDLEY_HAS_ATTRIBUTE(always_inline) || \
  1498. HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \
  1499. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1500. HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \
  1501. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1502. HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \
  1503. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1504. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  1505. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1506. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1507. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  1508. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1509. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1510. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  1511. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1512. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1513. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1514. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1515. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  1516. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1517. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
  1518. #define HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) HEDLEY_INLINE
  1519. #elif HEDLEY_MSVC_VERSION_CHECK(12, 0, 0)
  1520. #define HEDLEY_ALWAYS_INLINE __forceinline
  1521. #elif defined(__cplusplus) && (HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1522. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1523. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1524. HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \
  1525. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1526. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0))
  1527. #define HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
  1528. #elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
  1529. #define HEDLEY_ALWAYS_INLINE _Pragma("inline=forced")
  1530. #else
  1531. #define HEDLEY_ALWAYS_INLINE HEDLEY_INLINE
  1532. #endif
  1533. #if defined(HEDLEY_NEVER_INLINE)
  1534. #undef HEDLEY_NEVER_INLINE
  1535. #endif
  1536. #if HEDLEY_HAS_ATTRIBUTE(noinline) || HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \
  1537. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1538. HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \
  1539. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1540. HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \
  1541. HEDLEY_TI_VERSION_CHECK(15, 12, 0) || \
  1542. (HEDLEY_TI_ARMCL_VERSION_CHECK(4, 8, 0) && \
  1543. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1544. HEDLEY_TI_ARMCL_VERSION_CHECK(5, 2, 0) || \
  1545. (HEDLEY_TI_CL2000_VERSION_CHECK(6, 0, 0) && \
  1546. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1547. HEDLEY_TI_CL2000_VERSION_CHECK(6, 4, 0) || \
  1548. (HEDLEY_TI_CL430_VERSION_CHECK(4, 0, 0) && \
  1549. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1550. HEDLEY_TI_CL430_VERSION_CHECK(4, 3, 0) || \
  1551. (HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1552. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1553. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0) || \
  1554. HEDLEY_TI_CL7X_VERSION_CHECK(1, 2, 0) || \
  1555. HEDLEY_TI_CLPRU_VERSION_CHECK(2, 1, 0)
  1556. #define HEDLEY_NEVER_INLINE __attribute__((__noinline__))
  1557. #elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0)
  1558. #define HEDLEY_NEVER_INLINE __declspec(noinline)
  1559. #elif HEDLEY_PGI_VERSION_CHECK(10, 2, 0)
  1560. #define HEDLEY_NEVER_INLINE _Pragma("noinline")
  1561. #elif HEDLEY_TI_CL6X_VERSION_CHECK(6, 0, 0) && defined(__cplusplus)
  1562. #define HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;")
  1563. #elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
  1564. #define HEDLEY_NEVER_INLINE _Pragma("inline=never")
  1565. #elif HEDLEY_COMPCERT_VERSION_CHECK(3, 2, 0)
  1566. #define HEDLEY_NEVER_INLINE __attribute((noinline))
  1567. #elif HEDLEY_PELLES_VERSION_CHECK(9, 0, 0)
  1568. #define HEDLEY_NEVER_INLINE __declspec(noinline)
  1569. #else
  1570. #define HEDLEY_NEVER_INLINE
  1571. #endif
  1572. #if defined(HEDLEY_PRIVATE)
  1573. #undef HEDLEY_PRIVATE
  1574. #endif
  1575. #if defined(HEDLEY_PUBLIC)
  1576. #undef HEDLEY_PUBLIC
  1577. #endif
  1578. #if defined(HEDLEY_IMPORT)
  1579. #undef HEDLEY_IMPORT
  1580. #endif
  1581. #if defined(_WIN32) || defined(__CYGWIN__)
  1582. #define HEDLEY_PRIVATE
  1583. #define HEDLEY_PUBLIC __declspec(dllexport)
  1584. #define HEDLEY_IMPORT __declspec(dllimport)
  1585. #else
  1586. #if HEDLEY_HAS_ATTRIBUTE(visibility) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \
  1587. HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \
  1588. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1589. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1590. HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \
  1591. (defined(__TI_EABI__) && ((HEDLEY_TI_CL6X_VERSION_CHECK(7, 2, 0) && \
  1592. defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \
  1593. HEDLEY_TI_CL6X_VERSION_CHECK(7, 5, 0)))
  1594. #define HEDLEY_PRIVATE __attribute__((__visibility__("hidden")))
  1595. #define HEDLEY_PUBLIC __attribute__((__visibility__("default")))
  1596. #else
  1597. #define HEDLEY_PRIVATE
  1598. #define HEDLEY_PUBLIC
  1599. #endif
  1600. #define HEDLEY_IMPORT extern
  1601. #endif
  1602. #if defined(HEDLEY_NO_THROW)
  1603. #undef HEDLEY_NO_THROW
  1604. #endif
  1605. #if HEDLEY_HAS_ATTRIBUTE(nothrow) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \
  1606. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  1607. #define HEDLEY_NO_THROW __attribute__((__nothrow__))
  1608. #elif HEDLEY_MSVC_VERSION_CHECK(13, 1, 0) || HEDLEY_ARM_VERSION_CHECK(4, 1, 0)
  1609. #define HEDLEY_NO_THROW __declspec(nothrow)
  1610. #else
  1611. #define HEDLEY_NO_THROW
  1612. #endif
  1613. #if defined(HEDLEY_FALL_THROUGH)
  1614. #undef HEDLEY_FALL_THROUGH
  1615. #endif
  1616. #if HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough, 7, 0, 0) && \
  1617. !defined(HEDLEY_PGI_VERSION)
  1618. #define HEDLEY_FALL_THROUGH __attribute__((__fallthrough__))
  1619. #elif HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang, fallthrough)
  1620. #define HEDLEY_FALL_THROUGH \
  1621. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]])
  1622. #elif HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)
  1623. #define HEDLEY_FALL_THROUGH \
  1624. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]])
  1625. #elif defined(__fallthrough) /* SAL */
  1626. #define HEDLEY_FALL_THROUGH __fallthrough
  1627. #else
  1628. #define HEDLEY_FALL_THROUGH
  1629. #endif
  1630. #if defined(HEDLEY_RETURNS_NON_NULL)
  1631. #undef HEDLEY_RETURNS_NON_NULL
  1632. #endif
  1633. #if HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || HEDLEY_GCC_VERSION_CHECK(4, 9, 0)
  1634. #define HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__))
  1635. #elif defined(_Ret_notnull_) /* SAL */
  1636. #define HEDLEY_RETURNS_NON_NULL _Ret_notnull_
  1637. #else
  1638. #define HEDLEY_RETURNS_NON_NULL
  1639. #endif
  1640. #if defined(HEDLEY_ARRAY_PARAM)
  1641. #undef HEDLEY_ARRAY_PARAM
  1642. #endif
  1643. #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
  1644. !defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \
  1645. !defined(HEDLEY_PGI_VERSION) && !defined(HEDLEY_TINYC_VERSION)
  1646. #define HEDLEY_ARRAY_PARAM(name) (name)
  1647. #else
  1648. #define HEDLEY_ARRAY_PARAM(name)
  1649. #endif
  1650. #if defined(HEDLEY_IS_CONSTANT)
  1651. #undef HEDLEY_IS_CONSTANT
  1652. #endif
  1653. #if defined(HEDLEY_REQUIRE_CONSTEXPR)
  1654. #undef HEDLEY_REQUIRE_CONSTEXPR
  1655. #endif
  1656. /* HEDLEY_IS_CONSTEXPR_ is for
  1657. HEDLEY INTERNAL USE ONLY. API subject to change without notice. */
  1658. #if defined(HEDLEY_IS_CONSTEXPR_)
  1659. #undef HEDLEY_IS_CONSTEXPR_
  1660. #endif
  1661. #if HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \
  1662. HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \
  1663. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1664. HEDLEY_TINYC_VERSION_CHECK(0, 9, 19) || \
  1665. HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \
  1666. HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \
  1667. HEDLEY_TI_CL6X_VERSION_CHECK(6, 1, 0) || \
  1668. (HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) && !defined(__cplusplus)) || \
  1669. HEDLEY_CRAY_VERSION_CHECK(8, 1, 0)
  1670. #define HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr)
  1671. #endif
  1672. #if !defined(__cplusplus)
  1673. #if HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \
  1674. HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \
  1675. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \
  1676. HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \
  1677. HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \
  1678. HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || \
  1679. HEDLEY_TINYC_VERSION_CHECK(0, 9, 24)
  1680. #if defined(__INTPTR_TYPE__)
  1681. #define HEDLEY_IS_CONSTEXPR_(expr) \
  1682. __builtin_types_compatible_p( \
  1683. __typeof__((1 ? (void *)((__INTPTR_TYPE__)((expr)*0)) \
  1684. : (int *)0)), \
  1685. int *)
  1686. #else
  1687. #include <stdint.h>
  1688. #define HEDLEY_IS_CONSTEXPR_(expr) \
  1689. __builtin_types_compatible_p( \
  1690. __typeof__((1 ? (void *)((intptr_t)((expr)*0)) : (int *)0)), \
  1691. int *)
  1692. #endif
  1693. #elif (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \
  1694. !defined(HEDLEY_SUNPRO_VERSION) && !defined(HEDLEY_PGI_VERSION) && \
  1695. !defined(HEDLEY_IAR_VERSION)) || \
  1696. HEDLEY_HAS_EXTENSION(c_generic_selections) || \
  1697. HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || \
  1698. HEDLEY_INTEL_VERSION_CHECK(17, 0, 0) || \
  1699. HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \
  1700. HEDLEY_ARM_VERSION_CHECK(5, 3, 0)
  1701. #if defined(__INTPTR_TYPE__)
  1702. #define HEDLEY_IS_CONSTEXPR_(expr) \
  1703. _Generic((1 ? (void *)((__INTPTR_TYPE__)((expr)*0)) : (int *)0), \
  1704. int * : 1, void * : 0)
  1705. #else
  1706. #include <stdint.h>
  1707. #define HEDLEY_IS_CONSTEXPR_(expr) \
  1708. _Generic((1 ? (void *)((intptr_t)*0) : (int *)0), int * : 1, void * : 0)
  1709. #endif
  1710. #elif defined(HEDLEY_GCC_VERSION) || defined(HEDLEY_INTEL_VERSION) || \
  1711. defined(HEDLEY_TINYC_VERSION) || defined(HEDLEY_TI_ARMCL_VERSION) || \
  1712. HEDLEY_TI_CL430_VERSION_CHECK(18, 12, 0) || \
  1713. defined(HEDLEY_TI_CL2000_VERSION) || \
  1714. defined(HEDLEY_TI_CL6X_VERSION) || defined(HEDLEY_TI_CL7X_VERSION) || \
  1715. defined(HEDLEY_TI_CLPRU_VERSION) || defined(__clang__)
  1716. #define HEDLEY_IS_CONSTEXPR_(expr) \
  1717. (sizeof(void) != sizeof(*(1 ? ((void *)((expr)*0L)) : ((struct { \
  1718. char v[sizeof(void) * 2]; \
  1719. } *)1))))
  1720. #endif
  1721. #endif
  1722. #if defined(HEDLEY_IS_CONSTEXPR_)
  1723. #if !defined(HEDLEY_IS_CONSTANT)
  1724. #define HEDLEY_IS_CONSTANT(expr) HEDLEY_IS_CONSTEXPR_(expr)
  1725. #endif
  1726. #define HEDLEY_REQUIRE_CONSTEXPR(expr) \
  1727. (HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1))
  1728. #else
  1729. #if !defined(HEDLEY_IS_CONSTANT)
  1730. #define HEDLEY_IS_CONSTANT(expr) (0)
  1731. #endif
  1732. #define HEDLEY_REQUIRE_CONSTEXPR(expr) (expr)
  1733. #endif
  1734. #if defined(HEDLEY_BEGIN_C_DECLS)
  1735. #undef HEDLEY_BEGIN_C_DECLS
  1736. #endif
  1737. #if defined(HEDLEY_END_C_DECLS)
  1738. #undef HEDLEY_END_C_DECLS
  1739. #endif
  1740. #if defined(HEDLEY_C_DECL)
  1741. #undef HEDLEY_C_DECL
  1742. #endif
  1743. #if defined(__cplusplus)
  1744. #define HEDLEY_BEGIN_C_DECLS extern "C" {
  1745. #define HEDLEY_END_C_DECLS }
  1746. #define HEDLEY_C_DECL extern "C"
  1747. #else
  1748. #define HEDLEY_BEGIN_C_DECLS
  1749. #define HEDLEY_END_C_DECLS
  1750. #define HEDLEY_C_DECL
  1751. #endif
  1752. #if defined(HEDLEY_STATIC_ASSERT)
  1753. #undef HEDLEY_STATIC_ASSERT
  1754. #endif
  1755. #if !defined(__cplusplus) && \
  1756. ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
  1757. HEDLEY_HAS_FEATURE(c_static_assert) || \
  1758. HEDLEY_GCC_VERSION_CHECK(6, 0, 0) || \
  1759. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || defined(_Static_assert))
  1760. #define HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message)
  1761. #elif (defined(__cplusplus) && (__cplusplus >= 201103L)) || \
  1762. HEDLEY_MSVC_VERSION_CHECK(16, 0, 0)
  1763. #define HEDLEY_STATIC_ASSERT(expr, message) \
  1764. HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_( \
  1765. static_assert(expr, message))
  1766. #else
  1767. #define HEDLEY_STATIC_ASSERT(expr, message)
  1768. #endif
  1769. #if defined(HEDLEY_NULL)
  1770. #undef HEDLEY_NULL
  1771. #endif
  1772. #if defined(__cplusplus)
  1773. #if __cplusplus >= 201103L
  1774. #define HEDLEY_NULL HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr)
  1775. #elif defined(NULL)
  1776. #define HEDLEY_NULL NULL
  1777. #else
  1778. #define HEDLEY_NULL HEDLEY_STATIC_CAST(void *, 0)
  1779. #endif
  1780. #elif defined(NULL)
  1781. #define HEDLEY_NULL NULL
  1782. #else
  1783. #define HEDLEY_NULL ((void *)0)
  1784. #endif
  1785. #if defined(HEDLEY_MESSAGE)
  1786. #undef HEDLEY_MESSAGE
  1787. #endif
  1788. #if HEDLEY_HAS_WARNING("-Wunknown-pragmas")
  1789. #define HEDLEY_MESSAGE(msg) \
  1790. HEDLEY_DIAGNOSTIC_PUSH \
  1791. HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
  1792. HEDLEY_PRAGMA(message msg) \
  1793. HEDLEY_DIAGNOSTIC_POP
  1794. #elif HEDLEY_GCC_VERSION_CHECK(4, 4, 0) || HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  1795. #define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message msg)
  1796. #elif HEDLEY_CRAY_VERSION_CHECK(5, 0, 0)
  1797. #define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(_CRI message msg)
  1798. #elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0)
  1799. #define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg))
  1800. #elif HEDLEY_PELLES_VERSION_CHECK(2, 0, 0)
  1801. #define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg))
  1802. #else
  1803. #define HEDLEY_MESSAGE(msg)
  1804. #endif
  1805. #if defined(HEDLEY_WARNING)
  1806. #undef HEDLEY_WARNING
  1807. #endif
  1808. #if HEDLEY_HAS_WARNING("-Wunknown-pragmas")
  1809. #define HEDLEY_WARNING(msg) \
  1810. HEDLEY_DIAGNOSTIC_PUSH \
  1811. HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \
  1812. HEDLEY_PRAGMA(clang warning msg) \
  1813. HEDLEY_DIAGNOSTIC_POP
  1814. #elif HEDLEY_GCC_VERSION_CHECK(4, 8, 0) || \
  1815. HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \
  1816. HEDLEY_INTEL_VERSION_CHECK(13, 0, 0)
  1817. #define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(GCC warning msg)
  1818. #elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0)
  1819. #define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(message(msg))
  1820. #else
  1821. #define HEDLEY_WARNING(msg) HEDLEY_MESSAGE(msg)
  1822. #endif
  1823. #if defined(HEDLEY_REQUIRE)
  1824. #undef HEDLEY_REQUIRE
  1825. #endif
  1826. #if defined(HEDLEY_REQUIRE_MSG)
  1827. #undef HEDLEY_REQUIRE_MSG
  1828. #endif
  1829. #if HEDLEY_HAS_ATTRIBUTE(diagnose_if)
  1830. #if HEDLEY_HAS_WARNING("-Wgcc-compat")
  1831. #define HEDLEY_REQUIRE(expr) \
  1832. HEDLEY_DIAGNOSTIC_PUSH \
  1833. _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
  1834. __attribute__((diagnose_if(!(expr), #expr, "error"))) \
  1835. HEDLEY_DIAGNOSTIC_POP
  1836. #define HEDLEY_REQUIRE_MSG(expr, msg) \
  1837. HEDLEY_DIAGNOSTIC_PUSH \
  1838. _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \
  1839. __attribute__((diagnose_if(!(expr), msg, "error"))) \
  1840. HEDLEY_DIAGNOSTIC_POP
  1841. #else
  1842. #define HEDLEY_REQUIRE(expr) \
  1843. __attribute__((diagnose_if(!(expr), #expr, "error")))
  1844. #define HEDLEY_REQUIRE_MSG(expr, msg) \
  1845. __attribute__((diagnose_if(!(expr), msg, "error")))
  1846. #endif
  1847. #else
  1848. #define HEDLEY_REQUIRE(expr)
  1849. #define HEDLEY_REQUIRE_MSG(expr, msg)
  1850. #endif
  1851. #if defined(HEDLEY_FLAGS)
  1852. #undef HEDLEY_FLAGS
  1853. #endif
  1854. #if HEDLEY_HAS_ATTRIBUTE(flag_enum)
  1855. #define HEDLEY_FLAGS __attribute__((__flag_enum__))
  1856. #endif
  1857. #if defined(HEDLEY_FLAGS_CAST)
  1858. #undef HEDLEY_FLAGS_CAST
  1859. #endif
  1860. #if HEDLEY_INTEL_VERSION_CHECK(19, 0, 0)
  1861. #define HEDLEY_FLAGS_CAST(T, expr) \
  1862. (__extension__({ \
  1863. HEDLEY_DIAGNOSTIC_PUSH \
  1864. _Pragma("warning(disable:188)")((T)(expr)); \
  1865. HEDLEY_DIAGNOSTIC_POP \
  1866. }))
  1867. #else
  1868. #define HEDLEY_FLAGS_CAST(T, expr) HEDLEY_STATIC_CAST(T, expr)
  1869. #endif
  1870. #if defined(HEDLEY_EMPTY_BASES)
  1871. #undef HEDLEY_EMPTY_BASES
  1872. #endif
  1873. #if HEDLEY_MSVC_VERSION_CHECK(19, 0, 23918) && \
  1874. !HEDLEY_MSVC_VERSION_CHECK(20, 0, 0)
  1875. #define HEDLEY_EMPTY_BASES __declspec(empty_bases)
  1876. #else
  1877. #define HEDLEY_EMPTY_BASES
  1878. #endif
  1879. /* Remaining macros are deprecated. */
  1880. #if defined(HEDLEY_GCC_NOT_CLANG_VERSION_CHECK)
  1881. #undef HEDLEY_GCC_NOT_CLANG_VERSION_CHECK
  1882. #endif
  1883. #if defined(__clang__)
  1884. #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major, minor, patch) (0)
  1885. #else
  1886. #define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major, minor, patch) \
  1887. HEDLEY_GCC_VERSION_CHECK(major, minor, patch)
  1888. #endif
  1889. #if defined(HEDLEY_CLANG_HAS_ATTRIBUTE)
  1890. #undef HEDLEY_CLANG_HAS_ATTRIBUTE
  1891. #endif
  1892. #define HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) HEDLEY_HAS_ATTRIBUTE(attribute)
  1893. #if defined(HEDLEY_CLANG_HAS_CPP_ATTRIBUTE)
  1894. #undef HEDLEY_CLANG_HAS_CPP_ATTRIBUTE
  1895. #endif
  1896. #define HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) \
  1897. HEDLEY_HAS_CPP_ATTRIBUTE(attribute)
  1898. #if defined(HEDLEY_CLANG_HAS_BUILTIN)
  1899. #undef HEDLEY_CLANG_HAS_BUILTIN
  1900. #endif
  1901. #define HEDLEY_CLANG_HAS_BUILTIN(builtin) HEDLEY_HAS_BUILTIN(builtin)
  1902. #if defined(HEDLEY_CLANG_HAS_FEATURE)
  1903. #undef HEDLEY_CLANG_HAS_FEATURE
  1904. #endif
  1905. #define HEDLEY_CLANG_HAS_FEATURE(feature) HEDLEY_HAS_FEATURE(feature)
  1906. #if defined(HEDLEY_CLANG_HAS_EXTENSION)
  1907. #undef HEDLEY_CLANG_HAS_EXTENSION
  1908. #endif
  1909. #define HEDLEY_CLANG_HAS_EXTENSION(extension) HEDLEY_HAS_EXTENSION(extension)
  1910. #if defined(HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE)
  1911. #undef HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE
  1912. #endif
  1913. #define HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) \
  1914. HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute)
  1915. #if defined(HEDLEY_CLANG_HAS_WARNING)
  1916. #undef HEDLEY_CLANG_HAS_WARNING
  1917. #endif
  1918. #define HEDLEY_CLANG_HAS_WARNING(warning) HEDLEY_HAS_WARNING(warning)
  1919. #endif /* !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < X) */