CMakeCXXCompilerId.cpp 22 KB

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