CMakeCXXCompilerId.cpp 19 KB

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