CMakeCXXCompilerId.cpp 18 KB

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