CMakeCXXCompilerId.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  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__) || defined(__ICCV850__) || defined(__ICC8051__))
  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. # elif defined(__VXWORKS__)
  341. # define PLATFORM_ID "VxWorks"
  342. # else /* unknown platform */
  343. # define PLATFORM_ID
  344. # endif
  345. #elif defined(__INTEGRITY)
  346. # if defined(INT_178B)
  347. # define PLATFORM_ID "Integrity178"
  348. # else /* regular Integrity */
  349. # define PLATFORM_ID "Integrity"
  350. # endif
  351. #else /* unknown platform */
  352. # define PLATFORM_ID
  353. #endif
  354. /* For windows compilers MSVC and Intel we can determine
  355. the architecture of the compiler being used. This is because
  356. the compilers do not have flags that can change the architecture,
  357. but rather depend on which compiler is being used
  358. */
  359. #if defined(_WIN32) && defined(_MSC_VER)
  360. # if defined(_M_IA64)
  361. # define ARCHITECTURE_ID "IA64"
  362. # elif defined(_M_X64) || defined(_M_AMD64)
  363. # define ARCHITECTURE_ID "x64"
  364. # elif defined(_M_IX86)
  365. # define ARCHITECTURE_ID "X86"
  366. # elif defined(_M_ARM64)
  367. # define ARCHITECTURE_ID "ARM64"
  368. # elif defined(_M_ARM)
  369. # if _M_ARM == 4
  370. # define ARCHITECTURE_ID "ARMV4I"
  371. # elif _M_ARM == 5
  372. # define ARCHITECTURE_ID "ARMV5I"
  373. # else
  374. # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
  375. # endif
  376. # elif defined(_M_MIPS)
  377. # define ARCHITECTURE_ID "MIPS"
  378. # elif defined(_M_SH)
  379. # define ARCHITECTURE_ID "SHx"
  380. # else /* unknown architecture */
  381. # define ARCHITECTURE_ID ""
  382. # endif
  383. #elif defined(__WATCOMC__)
  384. # if defined(_M_I86)
  385. # define ARCHITECTURE_ID "I86"
  386. # elif defined(_M_IX86)
  387. # define ARCHITECTURE_ID "X86"
  388. # else /* unknown architecture */
  389. # define ARCHITECTURE_ID ""
  390. # endif
  391. #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
  392. # if defined(__ICCARM__)
  393. # define ARCHITECTURE_ID "ARM"
  394. # elif defined(__ICCRX__)
  395. # define ARCHITECTURE_ID "RX"
  396. # elif defined(__ICCRH850__)
  397. # define ARCHITECTURE_ID "RH850"
  398. # elif defined(__ICCRL78__)
  399. # define ARCHITECTURE_ID "RL78"
  400. # elif defined(__ICCRISCV__)
  401. # define ARCHITECTURE_ID "RISCV"
  402. # elif defined(__ICCAVR__)
  403. # define ARCHITECTURE_ID "AVR"
  404. # elif defined(__ICC430__)
  405. # define ARCHITECTURE_ID "MSP430"
  406. # elif defined(__ICCV850__)
  407. # define ARCHITECTURE_ID "V850"
  408. # elif defined(__ICC8051__)
  409. # define ARCHITECTURE_ID "8051"
  410. # else /* unknown architecture */
  411. # define ARCHITECTURE_ID ""
  412. # endif
  413. #elif defined(__ghs__)
  414. # if defined(__PPC64__)
  415. # define ARCHITECTURE_ID "PPC64"
  416. # elif defined(__ppc__)
  417. # define ARCHITECTURE_ID "PPC"
  418. # elif defined(__ARM__)
  419. # define ARCHITECTURE_ID "ARM"
  420. # elif defined(__x86_64__)
  421. # define ARCHITECTURE_ID "x64"
  422. # elif defined(__i386__)
  423. # define ARCHITECTURE_ID "X86"
  424. # else /* unknown architecture */
  425. # define ARCHITECTURE_ID ""
  426. # endif
  427. #else
  428. # define ARCHITECTURE_ID
  429. #endif
  430. /* Convert integer to decimal digit literals. */
  431. #define DEC(n) \
  432. ('0' + (((n) / 10000000)%10)), \
  433. ('0' + (((n) / 1000000)%10)), \
  434. ('0' + (((n) / 100000)%10)), \
  435. ('0' + (((n) / 10000)%10)), \
  436. ('0' + (((n) / 1000)%10)), \
  437. ('0' + (((n) / 100)%10)), \
  438. ('0' + (((n) / 10)%10)), \
  439. ('0' + ((n) % 10))
  440. /* Convert integer to hex digit literals. */
  441. #define HEX(n) \
  442. ('0' + ((n)>>28 & 0xF)), \
  443. ('0' + ((n)>>24 & 0xF)), \
  444. ('0' + ((n)>>20 & 0xF)), \
  445. ('0' + ((n)>>16 & 0xF)), \
  446. ('0' + ((n)>>12 & 0xF)), \
  447. ('0' + ((n)>>8 & 0xF)), \
  448. ('0' + ((n)>>4 & 0xF)), \
  449. ('0' + ((n) & 0xF))
  450. /* Construct a string literal encoding the version number components. */
  451. #ifdef COMPILER_VERSION_MAJOR
  452. char const info_version[] = {
  453. 'I', 'N', 'F', 'O', ':',
  454. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
  455. COMPILER_VERSION_MAJOR,
  456. # ifdef COMPILER_VERSION_MINOR
  457. '.', COMPILER_VERSION_MINOR,
  458. # ifdef COMPILER_VERSION_PATCH
  459. '.', COMPILER_VERSION_PATCH,
  460. # ifdef COMPILER_VERSION_TWEAK
  461. '.', COMPILER_VERSION_TWEAK,
  462. # endif
  463. # endif
  464. # endif
  465. ']','\0'};
  466. #endif
  467. /* Construct a string literal encoding the internal version number. */
  468. #ifdef COMPILER_VERSION_INTERNAL
  469. char const info_version_internal[] = {
  470. 'I', 'N', 'F', 'O', ':',
  471. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
  472. 'i','n','t','e','r','n','a','l','[',
  473. COMPILER_VERSION_INTERNAL,']','\0'};
  474. #endif
  475. /* Construct a string literal encoding the version number components. */
  476. #ifdef SIMULATE_VERSION_MAJOR
  477. char const info_simulate_version[] = {
  478. 'I', 'N', 'F', 'O', ':',
  479. 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
  480. SIMULATE_VERSION_MAJOR,
  481. # ifdef SIMULATE_VERSION_MINOR
  482. '.', SIMULATE_VERSION_MINOR,
  483. # ifdef SIMULATE_VERSION_PATCH
  484. '.', SIMULATE_VERSION_PATCH,
  485. # ifdef SIMULATE_VERSION_TWEAK
  486. '.', SIMULATE_VERSION_TWEAK,
  487. # endif
  488. # endif
  489. # endif
  490. ']','\0'};
  491. #endif
  492. /* Construct the string literal in pieces to prevent the source from
  493. getting matched. Store it in a pointer rather than an array
  494. because some compilers will just produce instructions to fill the
  495. array rather than assigning a pointer to a static array. */
  496. char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
  497. char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
  498. #if defined(__INTEL_COMPILER) && defined(_MSVC_LANG) && _MSVC_LANG < 201403L
  499. # if defined(__INTEL_CXX11_MODE__)
  500. # if defined(__cpp_aggregate_nsdmi)
  501. # define CXX_STD 201402L
  502. # else
  503. # define CXX_STD 201103L
  504. # endif
  505. # else
  506. # define CXX_STD 199711L
  507. # endif
  508. #elif defined(_MSC_VER) && defined(_MSVC_LANG)
  509. # define CXX_STD _MSVC_LANG
  510. #else
  511. # define CXX_STD __cplusplus
  512. #endif
  513. const char* info_language_dialect_default = "INFO" ":" "dialect_default["
  514. #if CXX_STD > 201703L
  515. "20"
  516. #elif CXX_STD >= 201703L
  517. "17"
  518. #elif CXX_STD >= 201402L
  519. "14"
  520. #elif CXX_STD >= 201103L
  521. "11"
  522. #else
  523. "98"
  524. #endif
  525. "]";
  526. /*--------------------------------------------------------------------------*/
  527. int main(int argc, char* argv[])
  528. {
  529. int require = 0;
  530. require += info_compiler[argc];
  531. require += info_platform[argc];
  532. #ifdef COMPILER_VERSION_MAJOR
  533. require += info_version[argc];
  534. #endif
  535. #ifdef COMPILER_VERSION_INTERNAL
  536. require += info_version_internal[argc];
  537. #endif
  538. #ifdef SIMULATE_ID
  539. require += info_simulate[argc];
  540. #endif
  541. #ifdef SIMULATE_VERSION_MAJOR
  542. require += info_simulate_version[argc];
  543. #endif
  544. #if defined(__CRAYXE) || defined(__CRAYXC)
  545. require += info_cray[argc];
  546. #endif
  547. require += info_language_dialect_default[argc];
  548. (void)argv;
  549. return require;
  550. }