CMakeOBJCXXCompilerId.mm 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. /* This source file must have a .cpp extension so that all C++ compilers
  2. recognize the extension without flags. Borland does not know .cxx for
  3. example. */
  4. #ifndef __cplusplus
  5. # error "An Objective-C compiler has been selected for Objective-C++."
  6. #endif
  7. /* Version number components: V=Version, R=Revision, P=Patch
  8. Version date components: YYYY=Year, MM=Month, DD=Day */
  9. #if defined(__INTEL_COMPILER) || defined(__ICC)
  10. # define COMPILER_ID "Intel"
  11. # if defined(_MSC_VER)
  12. # define SIMULATE_ID "MSVC"
  13. # endif
  14. # if defined(__GNUC__)
  15. # define SIMULATE_ID "GNU"
  16. # endif
  17. /* __INTEL_COMPILER = VRP prior to 2021, and then VVVV for 2021 and later,
  18. except that a few beta releases use the old format with V=2021. */
  19. # if __INTEL_COMPILER < 2021 || __INTEL_COMPILER == 202110 || __INTEL_COMPILER == 202111
  20. # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
  21. # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
  22. # if defined(__INTEL_COMPILER_UPDATE)
  23. # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
  24. # else
  25. # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
  26. # endif
  27. # else
  28. # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER)
  29. # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER_UPDATE)
  30. /* The third version component from --version is an update index,
  31. but no macro is provided for it. */
  32. # define COMPILER_VERSION_PATCH DEC(0)
  33. # endif
  34. # if defined(__INTEL_COMPILER_BUILD_DATE)
  35. /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
  36. # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
  37. # endif
  38. # if defined(_MSC_VER)
  39. /* _MSC_VER = VVRR */
  40. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  41. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  42. # endif
  43. # if defined(__GNUC__)
  44. # define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
  45. # elif defined(__GNUG__)
  46. # define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
  47. # endif
  48. # if defined(__GNUC_MINOR__)
  49. # define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
  50. # endif
  51. # if defined(__GNUC_PATCHLEVEL__)
  52. # define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  53. # endif
  54. #elif (defined(__clang__) && defined(__INTEL_CLANG_COMPILER)) || defined(__INTEL_LLVM_COMPILER)
  55. # define COMPILER_ID "IntelLLVM"
  56. #if defined(_MSC_VER)
  57. # define SIMULATE_ID "MSVC"
  58. #endif
  59. #if defined(__GNUC__)
  60. # define SIMULATE_ID "GNU"
  61. #endif
  62. /* __INTEL_LLVM_COMPILER = VVVVRP prior to 2021.2.0, VVVVRRPP for 2021.2.0 and
  63. * later. Look for 6 digit vs. 8 digit version number to decide encoding.
  64. * VVVV is no smaller than the current year when a version is released.
  65. */
  66. #if __INTEL_LLVM_COMPILER < 1000000L
  67. # define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/100)
  68. # define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/10 % 10)
  69. # define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 10)
  70. #else
  71. # define COMPILER_VERSION_MAJOR DEC(__INTEL_LLVM_COMPILER/10000)
  72. # define COMPILER_VERSION_MINOR DEC(__INTEL_LLVM_COMPILER/100 % 100)
  73. # define COMPILER_VERSION_PATCH DEC(__INTEL_LLVM_COMPILER % 100)
  74. #endif
  75. #if defined(_MSC_VER)
  76. /* _MSC_VER = VVRR */
  77. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  78. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  79. #endif
  80. #if defined(__GNUC__)
  81. # define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
  82. #elif defined(__GNUG__)
  83. # define SIMULATE_VERSION_MAJOR DEC(__GNUG__)
  84. #endif
  85. #if defined(__GNUC_MINOR__)
  86. # define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
  87. #endif
  88. #if defined(__GNUC_PATCHLEVEL__)
  89. # define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  90. #endif
  91. #elif defined(__PATHCC__)
  92. # define COMPILER_ID "PathScale"
  93. # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
  94. # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
  95. # if defined(__PATHCC_PATCHLEVEL__)
  96. # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
  97. # endif
  98. #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
  99. # define COMPILER_ID "Embarcadero"
  100. # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
  101. # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
  102. # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF)
  103. #elif defined(__BORLANDC__)
  104. # define COMPILER_ID "Borland"
  105. /* __BORLANDC__ = 0xVRR */
  106. # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
  107. # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
  108. #elif defined(__WATCOMC__) && __WATCOMC__ < 1200
  109. # define COMPILER_ID "Watcom"
  110. /* __WATCOMC__ = VVRR */
  111. # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
  112. # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
  113. # if (__WATCOMC__ % 10) > 0
  114. # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
  115. # endif
  116. #elif defined(__WATCOMC__)
  117. # define COMPILER_ID "OpenWatcom"
  118. /* __WATCOMC__ = VVRP + 1100 */
  119. # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
  120. # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
  121. # if (__WATCOMC__ % 10) > 0
  122. # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
  123. # endif
  124. #elif defined(__SUNPRO_C)
  125. # define COMPILER_ID "SunPro"
  126. # if __SUNPRO_C >= 0x5100
  127. /* __SUNPRO_C = 0xVRRP */
  128. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
  129. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
  130. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  131. # else
  132. /* __SUNPRO_CC = 0xVRP */
  133. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
  134. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
  135. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  136. # endif
  137. #elif defined(__HP_cc)
  138. # define COMPILER_ID "HP"
  139. /* __HP_cc = VVRRPP */
  140. # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
  141. # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
  142. # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
  143. #elif defined(__DECC)
  144. # define COMPILER_ID "Compaq"
  145. /* __DECC_VER = VVRRTPPPP */
  146. # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
  147. # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
  148. # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
  149. #elif defined(__IBMC__) && defined(__COMPILER_VER__)
  150. # define COMPILER_ID "zOS"
  151. /* __IBMC__ = VRP */
  152. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  153. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  154. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  155. #elif defined(__open_xl__) && defined(__clang__)
  156. # define COMPILER_ID "IBMClang"
  157. # define COMPILER_VERSION_MAJOR DEC(__open_xl_version__)
  158. # define COMPILER_VERSION_MINOR DEC(__open_xl_release__)
  159. # define COMPILER_VERSION_PATCH DEC(__open_xl_modification__)
  160. # define COMPILER_VERSION_TWEAK DEC(__open_xl_ptf_fix_level__)
  161. # define COMPILER_VERSION_INTERNAL_STR __clang_version__
  162. #elif defined(__ibmxl__) && defined(__clang__)
  163. # define COMPILER_ID "XLClang"
  164. # define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__)
  165. # define COMPILER_VERSION_MINOR DEC(__ibmxl_release__)
  166. # define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__)
  167. # define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__)
  168. #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800
  169. # define COMPILER_ID "XL"
  170. /* __IBMC__ = VRP */
  171. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  172. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  173. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  174. #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800
  175. # define COMPILER_ID "VisualAge"
  176. /* __IBMC__ = VRP */
  177. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  178. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  179. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  180. #elif defined(__NVCOMPILER)
  181. # define COMPILER_ID "NVHPC"
  182. # define COMPILER_VERSION_MAJOR DEC(__NVCOMPILER_MAJOR__)
  183. # define COMPILER_VERSION_MINOR DEC(__NVCOMPILER_MINOR__)
  184. # if defined(__NVCOMPILER_PATCHLEVEL__)
  185. # define COMPILER_VERSION_PATCH DEC(__NVCOMPILER_PATCHLEVEL__)
  186. # endif
  187. #elif defined(__PGI)
  188. # define COMPILER_ID "PGI"
  189. # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
  190. # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
  191. # if defined(__PGIC_PATCHLEVEL__)
  192. # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
  193. # endif
  194. #elif defined(__clang__) && defined(__cray__)
  195. # define COMPILER_ID "CrayClang"
  196. # define COMPILER_VERSION_MAJOR DEC(__cray_major__)
  197. # define COMPILER_VERSION_MINOR DEC(__cray_minor__)
  198. # define COMPILER_VERSION_PATCH DEC(__cray_patchlevel__)
  199. # define COMPILER_VERSION_INTERNAL_STR __clang_version__
  200. #elif defined(_CRAYC)
  201. # define COMPILER_ID "Cray"
  202. # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR)
  203. # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
  204. #elif defined(__TI_COMPILER_VERSION__)
  205. # define COMPILER_ID "TI"
  206. /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
  207. # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
  208. # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
  209. # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
  210. #elif defined(__CLANG_FUJITSU)
  211. # define COMPILER_ID "FujitsuClang"
  212. # define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
  213. # define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
  214. # define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
  215. # define COMPILER_VERSION_INTERNAL_STR __clang_version__
  216. #elif defined(__FUJITSU)
  217. # define COMPILER_ID "Fujitsu"
  218. # if defined(__FCC_version__)
  219. # define COMPILER_VERSION __FCC_version__
  220. # elif defined(__FCC_major__)
  221. # define COMPILER_VERSION_MAJOR DEC(__FCC_major__)
  222. # define COMPILER_VERSION_MINOR DEC(__FCC_minor__)
  223. # define COMPILER_VERSION_PATCH DEC(__FCC_patchlevel__)
  224. # endif
  225. # if defined(__fcc_version)
  226. # define COMPILER_VERSION_INTERNAL DEC(__fcc_version)
  227. # elif defined(__FCC_VERSION)
  228. # define COMPILER_VERSION_INTERNAL DEC(__FCC_VERSION)
  229. # endif
  230. #elif defined(__ghs__)
  231. # define COMPILER_ID "GHS"
  232. /* __GHS_VERSION_NUMBER = VVVVRP */
  233. # ifdef __GHS_VERSION_NUMBER
  234. # define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100)
  235. # define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10)
  236. # define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10)
  237. # endif
  238. #elif defined(__TASKING__)
  239. # define COMPILER_ID "Tasking"
  240. # define COMPILER_VERSION_MAJOR DEC(__VERSION__/1000)
  241. # define COMPILER_VERSION_MINOR DEC(__VERSION__ % 100)
  242. # define COMPILER_VERSION_INTERNAL DEC(__VERSION__)
  243. #elif defined(__ORANGEC__)
  244. # define COMPILER_ID "OrangeC"
  245. # define COMPILER_VERSION_MAJOR DEC(__ORANGEC_MAJOR__)
  246. # define COMPILER_VERSION_MINOR DEC(__ORANGEC_MINOR__)
  247. # define COMPILER_VERSION_PATCH DEC(__ORANGEC_PATCHLEVEL__)
  248. #elif defined(__RENESAS__)
  249. # define COMPILER_ID "Renesas"
  250. /* __RENESAS_VERSION__ = 0xVVRRPP00 */
  251. # define COMPILER_VERSION_MAJOR HEX(__RENESAS_VERSION__ >> 24 & 0xFF)
  252. # define COMPILER_VERSION_MINOR HEX(__RENESAS_VERSION__ >> 16 & 0xFF)
  253. # define COMPILER_VERSION_PATCH HEX(__RENESAS_VERSION__ >> 8 & 0xFF)
  254. #elif defined(__SCO_VERSION__)
  255. # define COMPILER_ID "SCO"
  256. #elif defined(__ARMCC_VERSION) && !defined(__clang__)
  257. # define COMPILER_ID "ARMCC"
  258. #if __ARMCC_VERSION >= 1000000
  259. /* __ARMCC_VERSION = VRRPPPP */
  260. # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
  261. # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
  262. # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
  263. #else
  264. /* __ARMCC_VERSION = VRPPPP */
  265. # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
  266. # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
  267. # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
  268. #endif
  269. #elif defined(__clang__) && defined(__apple_build_version__)
  270. # define COMPILER_ID "AppleClang"
  271. # if defined(_MSC_VER)
  272. # define SIMULATE_ID "MSVC"
  273. # endif
  274. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  275. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  276. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  277. # if defined(_MSC_VER)
  278. /* _MSC_VER = VVRR */
  279. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  280. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  281. # endif
  282. # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
  283. #elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
  284. # define COMPILER_ID "ARMClang"
  285. # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
  286. # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
  287. # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION/100 % 100)
  288. # define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
  289. #elif defined(__clang__) && defined(__ti__)
  290. # define COMPILER_ID "TIClang"
  291. # define COMPILER_VERSION_MAJOR DEC(__ti_major__)
  292. # define COMPILER_VERSION_MINOR DEC(__ti_minor__)
  293. # define COMPILER_VERSION_PATCH DEC(__ti_patchlevel__)
  294. # define COMPILER_VERSION_INTERNAL DEC(__ti_version__)
  295. #elif defined(__clang__)
  296. # define COMPILER_ID "Clang"
  297. # if defined(_MSC_VER)
  298. # define SIMULATE_ID "MSVC"
  299. # endif
  300. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  301. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  302. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  303. # if defined(_MSC_VER)
  304. /* _MSC_VER = VVRR */
  305. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  306. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  307. # endif
  308. #elif defined(__LCC__) && (defined(__GNUC__) || defined(__GNUG__) || defined(__MCST__))
  309. # define COMPILER_ID "LCC"
  310. # define COMPILER_VERSION_MAJOR DEC(__LCC__ / 100)
  311. # define COMPILER_VERSION_MINOR DEC(__LCC__ % 100)
  312. # if defined(__LCC_MINOR__)
  313. # define COMPILER_VERSION_PATCH DEC(__LCC_MINOR__)
  314. # endif
  315. # if defined(__GNUC__) && defined(__GNUC_MINOR__)
  316. # define SIMULATE_ID "GNU"
  317. # define SIMULATE_VERSION_MAJOR DEC(__GNUC__)
  318. # define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__)
  319. # if defined(__GNUC_PATCHLEVEL__)
  320. # define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  321. # endif
  322. # endif
  323. #elif defined(__GNUC__)
  324. # define COMPILER_ID "GNU"
  325. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  326. # if defined(__GNUC_MINOR__)
  327. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  328. # endif
  329. # if defined(__GNUC_PATCHLEVEL__)
  330. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  331. # endif
  332. #elif defined(_MSC_VER)
  333. # define COMPILER_ID "MSVC"
  334. /* _MSC_VER = VVRR */
  335. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  336. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  337. # if defined(_MSC_FULL_VER)
  338. # if _MSC_VER >= 1400
  339. /* _MSC_FULL_VER = VVRRPPPPP */
  340. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  341. # else
  342. /* _MSC_FULL_VER = VVRRPPPP */
  343. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  344. # endif
  345. # endif
  346. # if defined(_MSC_BUILD)
  347. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  348. # endif
  349. #elif defined(_ADI_COMPILER)
  350. # define COMPILER_ID "ADSP"
  351. #if defined(__VERSIONNUM__)
  352. /* __VERSIONNUM__ = 0xVVRRPPTT */
  353. # define COMPILER_VERSION_MAJOR DEC(__VERSIONNUM__ >> 24 & 0xFF)
  354. # define COMPILER_VERSION_MINOR DEC(__VERSIONNUM__ >> 16 & 0xFF)
  355. # define COMPILER_VERSION_PATCH DEC(__VERSIONNUM__ >> 8 & 0xFF)
  356. # define COMPILER_VERSION_TWEAK DEC(__VERSIONNUM__ & 0xFF)
  357. #endif
  358. #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
  359. # define COMPILER_ID "IAR"
  360. # if defined(__VER__) && defined(__ICCARM__)
  361. # define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000)
  362. # define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000)
  363. # define COMPILER_VERSION_PATCH DEC((__VER__) % 1000)
  364. # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
  365. # elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__) || defined(__ICCSTM8__))
  366. # define COMPILER_VERSION_MAJOR DEC((__VER__) / 100)
  367. # define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100))
  368. # define COMPILER_VERSION_PATCH DEC(__SUBVERSION__)
  369. # define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__)
  370. # endif
  371. #elif defined(__DCC__) && defined(_DIAB_TOOL)
  372. # define COMPILER_ID "Diab"
  373. # define COMPILER_VERSION_MAJOR DEC(__VERSION_MAJOR_NUMBER__)
  374. # define COMPILER_VERSION_MINOR DEC(__VERSION_MINOR_NUMBER__)
  375. # define COMPILER_VERSION_PATCH DEC(__VERSION_ARCH_FEATURE_NUMBER__)
  376. # define COMPILER_VERSION_TWEAK DEC(__VERSION_BUG_FIX_NUMBER__)
  377. /* These compilers are either not known or too old to define an
  378. identification macro. Try to identify the platform and guess that
  379. it is the native compiler. */
  380. #elif defined(__hpux) || defined(__hpua)
  381. # define COMPILER_ID "HP"
  382. #else /* unknown compiler */
  383. # define COMPILER_ID ""
  384. #endif
  385. /* Construct the string literal in pieces to prevent the source from
  386. getting matched. Store it in a pointer rather than an array
  387. because some compilers will just produce instructions to fill the
  388. array rather than assigning a pointer to a static array. */
  389. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  390. #ifdef SIMULATE_ID
  391. char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
  392. #endif
  393. #ifdef __QNXNTO__
  394. char const* qnxnto = "INFO" ":" "qnxnto[]";
  395. #endif
  396. #define STRINGIFY_HELPER(X) #X
  397. #define STRINGIFY(X) STRINGIFY_HELPER(X)
  398. /* Identify known platforms by name. */
  399. #if defined(__linux) || defined(__linux__) || defined(linux)
  400. # define PLATFORM_ID "Linux"
  401. #elif defined(__MSYS__)
  402. # define PLATFORM_ID "MSYS"
  403. #elif defined(__CYGWIN__)
  404. # define PLATFORM_ID "Cygwin"
  405. #elif defined(__MINGW32__)
  406. # define PLATFORM_ID "MinGW"
  407. #elif defined(__APPLE__)
  408. # define PLATFORM_ID "Darwin"
  409. #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
  410. # define PLATFORM_ID "Windows"
  411. #elif defined(__FreeBSD__) || defined(__FreeBSD)
  412. # define PLATFORM_ID "FreeBSD"
  413. #elif defined(__NetBSD__) || defined(__NetBSD)
  414. # define PLATFORM_ID "NetBSD"
  415. #elif defined(__OpenBSD__) || defined(__OPENBSD)
  416. # define PLATFORM_ID "OpenBSD"
  417. #elif defined(__sun) || defined(sun)
  418. # define PLATFORM_ID "SunOS"
  419. #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
  420. # define PLATFORM_ID "AIX"
  421. #elif defined(__hpux) || defined(__hpux__)
  422. # define PLATFORM_ID "HP-UX"
  423. #elif defined(__HAIKU__)
  424. # define PLATFORM_ID "Haiku"
  425. #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
  426. # define PLATFORM_ID "BeOS"
  427. #elif defined(__QNX__) || defined(__QNXNTO__)
  428. # define PLATFORM_ID "QNX"
  429. #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
  430. # define PLATFORM_ID "Tru64"
  431. #elif defined(__riscos) || defined(__riscos__)
  432. # define PLATFORM_ID "RISCos"
  433. #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
  434. # define PLATFORM_ID "SINIX"
  435. #elif defined(__UNIX_SV__)
  436. # define PLATFORM_ID "UNIX_SV"
  437. #elif defined(__bsdos__)
  438. # define PLATFORM_ID "BSDOS"
  439. #elif defined(_MPRAS) || defined(MPRAS)
  440. # define PLATFORM_ID "MP-RAS"
  441. #elif defined(__osf) || defined(__osf__)
  442. # define PLATFORM_ID "OSF1"
  443. #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
  444. # define PLATFORM_ID "SCO_SV"
  445. #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
  446. # define PLATFORM_ID "ULTRIX"
  447. #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
  448. # define PLATFORM_ID "Xenix"
  449. #elif defined(__WATCOMC__)
  450. # if defined(__LINUX__)
  451. # define PLATFORM_ID "Linux"
  452. # elif defined(__DOS__)
  453. # define PLATFORM_ID "DOS"
  454. # elif defined(__OS2__)
  455. # define PLATFORM_ID "OS2"
  456. # elif defined(__WINDOWS__)
  457. # define PLATFORM_ID "Windows3x"
  458. # elif defined(__VXWORKS__)
  459. # define PLATFORM_ID "VxWorks"
  460. # else /* unknown platform */
  461. # define PLATFORM_ID
  462. # endif
  463. #elif defined(__INTEGRITY)
  464. # if defined(INT_178B)
  465. # define PLATFORM_ID "Integrity178"
  466. # else /* regular Integrity */
  467. # define PLATFORM_ID "Integrity"
  468. # endif
  469. # elif defined(_ADI_COMPILER)
  470. # define PLATFORM_ID "ADSP"
  471. #else /* unknown platform */
  472. # define PLATFORM_ID
  473. #endif
  474. /* For windows compilers MSVC and Intel we can determine
  475. the architecture of the compiler being used. This is because
  476. the compilers do not have flags that can change the architecture,
  477. but rather depend on which compiler is being used
  478. */
  479. #if defined(_WIN32) && defined(_MSC_VER)
  480. # if defined(_M_IA64)
  481. # define ARCHITECTURE_ID "IA64"
  482. # elif defined(_M_ARM64EC)
  483. # define ARCHITECTURE_ID "ARM64EC"
  484. # elif defined(_M_X64) || defined(_M_AMD64)
  485. # define ARCHITECTURE_ID "x64"
  486. # elif defined(_M_IX86)
  487. # define ARCHITECTURE_ID "X86"
  488. # elif defined(_M_ARM64)
  489. # define ARCHITECTURE_ID "ARM64"
  490. # elif defined(_M_ARM)
  491. # if _M_ARM == 4
  492. # define ARCHITECTURE_ID "ARMV4I"
  493. # elif _M_ARM == 5
  494. # define ARCHITECTURE_ID "ARMV5I"
  495. # else
  496. # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
  497. # endif
  498. # elif defined(_M_MIPS)
  499. # define ARCHITECTURE_ID "MIPS"
  500. # elif defined(_M_SH)
  501. # define ARCHITECTURE_ID "SHx"
  502. # else /* unknown architecture */
  503. # define ARCHITECTURE_ID ""
  504. # endif
  505. #elif defined(__WATCOMC__)
  506. # if defined(_M_I86)
  507. # define ARCHITECTURE_ID "I86"
  508. # elif defined(_M_IX86)
  509. # define ARCHITECTURE_ID "X86"
  510. # else /* unknown architecture */
  511. # define ARCHITECTURE_ID ""
  512. # endif
  513. #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
  514. # if defined(__ICCARM__)
  515. # define ARCHITECTURE_ID "ARM"
  516. # elif defined(__ICCRX__)
  517. # define ARCHITECTURE_ID "RX"
  518. # elif defined(__ICCRH850__)
  519. # define ARCHITECTURE_ID "RH850"
  520. # elif defined(__ICCRL78__)
  521. # define ARCHITECTURE_ID "RL78"
  522. # elif defined(__ICCRISCV__)
  523. # define ARCHITECTURE_ID "RISCV"
  524. # elif defined(__ICCAVR__)
  525. # define ARCHITECTURE_ID "AVR"
  526. # elif defined(__ICC430__)
  527. # define ARCHITECTURE_ID "MSP430"
  528. # elif defined(__ICCV850__)
  529. # define ARCHITECTURE_ID "V850"
  530. # elif defined(__ICC8051__)
  531. # define ARCHITECTURE_ID "8051"
  532. # elif defined(__ICCSTM8__)
  533. # define ARCHITECTURE_ID "STM8"
  534. # else /* unknown architecture */
  535. # define ARCHITECTURE_ID ""
  536. # endif
  537. #elif defined(__ghs__)
  538. # if defined(__PPC64__)
  539. # define ARCHITECTURE_ID "PPC64"
  540. # elif defined(__ppc__)
  541. # define ARCHITECTURE_ID "PPC"
  542. # elif defined(__ARM__)
  543. # define ARCHITECTURE_ID "ARM"
  544. # elif defined(__x86_64__)
  545. # define ARCHITECTURE_ID "x64"
  546. # elif defined(__i386__)
  547. # define ARCHITECTURE_ID "X86"
  548. # else /* unknown architecture */
  549. # define ARCHITECTURE_ID ""
  550. # endif
  551. #elif defined(__clang__) && defined(__ti__)
  552. # if defined(__ARM_ARCH)
  553. # define ARCHITECTURE_ID "ARM"
  554. # else /* unknown architecture */
  555. # define ARCHITECTURE_ID ""
  556. # endif
  557. #elif defined(__TI_COMPILER_VERSION__)
  558. # if defined(__TI_ARM__)
  559. # define ARCHITECTURE_ID "ARM"
  560. # elif defined(__MSP430__)
  561. # define ARCHITECTURE_ID "MSP430"
  562. # elif defined(__TMS320C28XX__)
  563. # define ARCHITECTURE_ID "TMS320C28x"
  564. # elif defined(__TMS320C6X__) || defined(_TMS320C6X)
  565. # define ARCHITECTURE_ID "TMS320C6x"
  566. # else /* unknown architecture */
  567. # define ARCHITECTURE_ID ""
  568. # endif
  569. # elif defined(__ADSPSHARC__)
  570. # define ARCHITECTURE_ID "SHARC"
  571. # elif defined(__ADSPBLACKFIN__)
  572. # define ARCHITECTURE_ID "Blackfin"
  573. #elif defined(__TASKING__)
  574. # if defined(__CTC__) || defined(__CPTC__)
  575. # define ARCHITECTURE_ID "TriCore"
  576. # elif defined(__CMCS__)
  577. # define ARCHITECTURE_ID "MCS"
  578. # elif defined(__CARM__) || defined(__CPARM__)
  579. # define ARCHITECTURE_ID "ARM"
  580. # elif defined(__CARC__)
  581. # define ARCHITECTURE_ID "ARC"
  582. # elif defined(__C51__)
  583. # define ARCHITECTURE_ID "8051"
  584. # elif defined(__CPCP__)
  585. # define ARCHITECTURE_ID "PCP"
  586. # else
  587. # define ARCHITECTURE_ID ""
  588. # endif
  589. #elif defined(__RENESAS__)
  590. # if defined(__CCRX__)
  591. # define ARCHITECTURE_ID "RX"
  592. # elif defined(__CCRL__)
  593. # define ARCHITECTURE_ID "RL78"
  594. # elif defined(__CCRH__)
  595. # define ARCHITECTURE_ID "RH850"
  596. # else
  597. # define ARCHITECTURE_ID ""
  598. # endif
  599. #else
  600. # define ARCHITECTURE_ID
  601. #endif
  602. /* Convert integer to decimal digit literals. */
  603. #define DEC(n) \
  604. ('0' + (((n) / 10000000)%10)), \
  605. ('0' + (((n) / 1000000)%10)), \
  606. ('0' + (((n) / 100000)%10)), \
  607. ('0' + (((n) / 10000)%10)), \
  608. ('0' + (((n) / 1000)%10)), \
  609. ('0' + (((n) / 100)%10)), \
  610. ('0' + (((n) / 10)%10)), \
  611. ('0' + ((n) % 10))
  612. /* Convert integer to hex digit literals. */
  613. #define HEX(n) \
  614. ('0' + ((n)>>28 & 0xF)), \
  615. ('0' + ((n)>>24 & 0xF)), \
  616. ('0' + ((n)>>20 & 0xF)), \
  617. ('0' + ((n)>>16 & 0xF)), \
  618. ('0' + ((n)>>12 & 0xF)), \
  619. ('0' + ((n)>>8 & 0xF)), \
  620. ('0' + ((n)>>4 & 0xF)), \
  621. ('0' + ((n) & 0xF))
  622. /* Construct a string literal encoding the version number. */
  623. #ifdef COMPILER_VERSION
  624. char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]";
  625. /* Construct a string literal encoding the version number components. */
  626. #elif defined(COMPILER_VERSION_MAJOR)
  627. char const info_version[] = {
  628. 'I', 'N', 'F', 'O', ':',
  629. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
  630. COMPILER_VERSION_MAJOR,
  631. # ifdef COMPILER_VERSION_MINOR
  632. '.', COMPILER_VERSION_MINOR,
  633. # ifdef COMPILER_VERSION_PATCH
  634. '.', COMPILER_VERSION_PATCH,
  635. # ifdef COMPILER_VERSION_TWEAK
  636. '.', COMPILER_VERSION_TWEAK,
  637. # endif
  638. # endif
  639. # endif
  640. ']','\0'};
  641. #endif
  642. /* Construct a string literal encoding the internal version number. */
  643. #ifdef COMPILER_VERSION_INTERNAL
  644. char const info_version_internal[] = {
  645. 'I', 'N', 'F', 'O', ':',
  646. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
  647. 'i','n','t','e','r','n','a','l','[',
  648. COMPILER_VERSION_INTERNAL,']','\0'};
  649. #elif defined(COMPILER_VERSION_INTERNAL_STR)
  650. char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]";
  651. #endif
  652. /* Construct a string literal encoding the version number components. */
  653. #ifdef SIMULATE_VERSION_MAJOR
  654. char const info_simulate_version[] = {
  655. 'I', 'N', 'F', 'O', ':',
  656. 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
  657. SIMULATE_VERSION_MAJOR,
  658. # ifdef SIMULATE_VERSION_MINOR
  659. '.', SIMULATE_VERSION_MINOR,
  660. # ifdef SIMULATE_VERSION_PATCH
  661. '.', SIMULATE_VERSION_PATCH,
  662. # ifdef SIMULATE_VERSION_TWEAK
  663. '.', SIMULATE_VERSION_TWEAK,
  664. # endif
  665. # endif
  666. # endif
  667. ']','\0'};
  668. #endif
  669. /* Construct the string literal in pieces to prevent the source from
  670. getting matched. Store it in a pointer rather than an array
  671. because some compilers will just produce instructions to fill the
  672. array rather than assigning a pointer to a static array. */
  673. char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
  674. char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
  675. #define CXX_STD_98 199711L
  676. #define CXX_STD_11 201103L
  677. #define CXX_STD_14 201402L
  678. #define CXX_STD_17 201703L
  679. #define CXX_STD_20 202002L
  680. #define CXX_STD_23 202302L
  681. #define CXX_STD __cplusplus
  682. const char* info_language_standard_default = "INFO" ":" "standard_default["
  683. #if CXX_STD > CXX_STD_23
  684. "26"
  685. #elif CXX_STD > CXX_STD_20
  686. "23"
  687. #elif CXX_STD > CXX_STD_17
  688. "20"
  689. #elif CXX_STD > CXX_STD_14
  690. "17"
  691. #elif CXX_STD > CXX_STD_11
  692. "14"
  693. #elif CXX_STD >= CXX_STD_11
  694. "11"
  695. #else
  696. "98"
  697. #endif
  698. "]";
  699. const char* info_language_extensions_default = "INFO" ":" "extensions_default["
  700. #if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__)
  701. "ON"
  702. #else
  703. "OFF"
  704. #endif
  705. "]";
  706. /*--------------------------------------------------------------------------*/
  707. int main(int argc, char* argv[])
  708. {
  709. int require = 0;
  710. require += info_compiler[argc];
  711. require += info_platform[argc];
  712. #ifdef COMPILER_VERSION_MAJOR
  713. require += info_version[argc];
  714. #endif
  715. #if defined(COMPILER_VERSION_INTERNAL) || defined(COMPILER_VERSION_INTERNAL_STR)
  716. require += info_version_internal[argc];
  717. #endif
  718. #ifdef SIMULATE_ID
  719. require += info_simulate[argc];
  720. #endif
  721. #ifdef SIMULATE_VERSION_MAJOR
  722. require += info_simulate_version[argc];
  723. #endif
  724. require += info_language_standard_default[argc];
  725. require += info_language_extensions_default[argc];
  726. (void)argv;
  727. return require;
  728. }