CMakeCXXCompilerId.cpp 22 KB

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