CMakeCCompilerId.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. #ifdef __cplusplus
  2. # error "A C++ compiler has been selected for C."
  3. #endif
  4. #if defined(__18CXX)
  5. # define ID_VOID_MAIN
  6. #endif
  7. #if defined(__CLASSIC_C__)
  8. /* cv-qualifiers did not exist in K&R C */
  9. # define const
  10. # define volatile
  11. #endif
  12. /* Version number components: V=Version, R=Revision, P=Patch
  13. Version date components: YYYY=Year, MM=Month, DD=Day */
  14. #if 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_C)
  84. # define COMPILER_ID "SunPro"
  85. # if __SUNPRO_C >= 0x5100
  86. /* __SUNPRO_C = 0xVRRP */
  87. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
  88. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
  89. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  90. # else
  91. /* __SUNPRO_CC = 0xVRP */
  92. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
  93. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
  94. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  95. # endif
  96. #elif defined(__HP_cc)
  97. # define COMPILER_ID "HP"
  98. /* __HP_cc = VVRRPP */
  99. # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
  100. # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
  101. # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
  102. #elif defined(__DECC)
  103. # define COMPILER_ID "Compaq"
  104. /* __DECC_VER = VVRRTPPPP */
  105. # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
  106. # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
  107. # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
  108. #elif defined(__IBMC__) && defined(__COMPILER_VER__)
  109. # define COMPILER_ID "zOS"
  110. /* __IBMC__ = VRP */
  111. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  112. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  113. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 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(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800
  121. # define COMPILER_ID "XL"
  122. /* __IBMC__ = VRP */
  123. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  124. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  125. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  126. #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800
  127. # define COMPILER_ID "VisualAge"
  128. /* __IBMC__ = VRP */
  129. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  130. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  131. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 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(__TINYC__)
  160. # define COMPILER_ID "TinyCC"
  161. #elif defined(__BCC__)
  162. # define COMPILER_ID "Bruce"
  163. #elif defined(__SCO_VERSION__)
  164. # define COMPILER_ID "SCO"
  165. #elif defined(__ARMCC_VERSION) && !defined(__clang__)
  166. # define COMPILER_ID "ARMCC"
  167. #if __ARMCC_VERSION >= 1000000
  168. /* __ARMCC_VERSION = VRRPPPP */
  169. # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000)
  170. # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100)
  171. # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
  172. #else
  173. /* __ARMCC_VERSION = VRPPPP */
  174. # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000)
  175. # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10)
  176. # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000)
  177. #endif
  178. #elif defined(__clang__) && defined(__apple_build_version__)
  179. # define COMPILER_ID "AppleClang"
  180. # if defined(_MSC_VER)
  181. # define SIMULATE_ID "MSVC"
  182. # endif
  183. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  184. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  185. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  186. # if defined(_MSC_VER)
  187. /* _MSC_VER = VVRR */
  188. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  189. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  190. # endif
  191. # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
  192. #elif defined(__clang__) && defined(__ARMCOMPILER_VERSION)
  193. # define COMPILER_ID "ARMClang"
  194. # define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000)
  195. # define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100)
  196. # define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000)
  197. # define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION)
  198. #elif defined(__clang__)
  199. # define COMPILER_ID "Clang"
  200. # if defined(_MSC_VER)
  201. # define SIMULATE_ID "MSVC"
  202. # endif
  203. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  204. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  205. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  206. # if defined(_MSC_VER)
  207. /* _MSC_VER = VVRR */
  208. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  209. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  210. # endif
  211. #elif defined(__GNUC__)
  212. # define COMPILER_ID "GNU"
  213. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  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. #elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC)
  259. # define COMPILER_ID "SDCC"
  260. # if defined(__SDCC_VERSION_MAJOR)
  261. # define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR)
  262. # define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR)
  263. # define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH)
  264. # else
  265. /* SDCC = VRP */
  266. # define COMPILER_VERSION_MAJOR DEC(SDCC/100)
  267. # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
  268. # define COMPILER_VERSION_PATCH DEC(SDCC % 10)
  269. # endif
  270. /* These compilers are either not known or too old to define an
  271. identification macro. Try to identify the platform and guess that
  272. it is the native compiler. */
  273. #elif defined(__hpux) || defined(__hpua)
  274. # define COMPILER_ID "HP"
  275. #else /* unknown compiler */
  276. # define COMPILER_ID ""
  277. #endif
  278. /* Construct the string literal in pieces to prevent the source from
  279. getting matched. Store it in a pointer rather than an array
  280. because some compilers will just produce instructions to fill the
  281. array rather than assigning a pointer to a static array. */
  282. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  283. #ifdef SIMULATE_ID
  284. char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
  285. #endif
  286. #ifdef __QNXNTO__
  287. char const* qnxnto = "INFO" ":" "qnxnto[]";
  288. #endif
  289. #if defined(__CRAYXE) || defined(__CRAYXC)
  290. char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
  291. #endif
  292. #define STRINGIFY_HELPER(X) #X
  293. #define STRINGIFY(X) STRINGIFY_HELPER(X)
  294. /* Identify known platforms by name. */
  295. #if defined(__linux) || defined(__linux__) || defined(linux)
  296. # define PLATFORM_ID "Linux"
  297. #elif defined(__CYGWIN__)
  298. # define PLATFORM_ID "Cygwin"
  299. #elif defined(__MINGW32__)
  300. # define PLATFORM_ID "MinGW"
  301. #elif defined(__APPLE__)
  302. # define PLATFORM_ID "Darwin"
  303. #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
  304. # define PLATFORM_ID "Windows"
  305. #elif defined(__FreeBSD__) || defined(__FreeBSD)
  306. # define PLATFORM_ID "FreeBSD"
  307. #elif defined(__NetBSD__) || defined(__NetBSD)
  308. # define PLATFORM_ID "NetBSD"
  309. #elif defined(__OpenBSD__) || defined(__OPENBSD)
  310. # define PLATFORM_ID "OpenBSD"
  311. #elif defined(__sun) || defined(sun)
  312. # define PLATFORM_ID "SunOS"
  313. #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
  314. # define PLATFORM_ID "AIX"
  315. #elif defined(__hpux) || defined(__hpux__)
  316. # define PLATFORM_ID "HP-UX"
  317. #elif defined(__HAIKU__)
  318. # define PLATFORM_ID "Haiku"
  319. #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
  320. # define PLATFORM_ID "BeOS"
  321. #elif defined(__QNX__) || defined(__QNXNTO__)
  322. # define PLATFORM_ID "QNX"
  323. #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
  324. # define PLATFORM_ID "Tru64"
  325. #elif defined(__riscos) || defined(__riscos__)
  326. # define PLATFORM_ID "RISCos"
  327. #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
  328. # define PLATFORM_ID "SINIX"
  329. #elif defined(__UNIX_SV__)
  330. # define PLATFORM_ID "UNIX_SV"
  331. #elif defined(__bsdos__)
  332. # define PLATFORM_ID "BSDOS"
  333. #elif defined(_MPRAS) || defined(MPRAS)
  334. # define PLATFORM_ID "MP-RAS"
  335. #elif defined(__osf) || defined(__osf__)
  336. # define PLATFORM_ID "OSF1"
  337. #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
  338. # define PLATFORM_ID "SCO_SV"
  339. #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
  340. # define PLATFORM_ID "ULTRIX"
  341. #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
  342. # define PLATFORM_ID "Xenix"
  343. #elif defined(__WATCOMC__)
  344. # if defined(__LINUX__)
  345. # define PLATFORM_ID "Linux"
  346. # elif defined(__DOS__)
  347. # define PLATFORM_ID "DOS"
  348. # elif defined(__OS2__)
  349. # define PLATFORM_ID "OS2"
  350. # elif defined(__WINDOWS__)
  351. # define PLATFORM_ID "Windows3x"
  352. # else /* unknown platform */
  353. # define PLATFORM_ID
  354. # endif
  355. #elif defined(__INTEGRITY)
  356. # if defined(INT_178B)
  357. # define PLATFORM_ID "Integrity178"
  358. # else /* regular Integrity */
  359. # define PLATFORM_ID "Integrity"
  360. # endif
  361. #else /* unknown platform */
  362. # define PLATFORM_ID
  363. #endif
  364. /* For windows compilers MSVC and Intel we can determine
  365. the architecture of the compiler being used. This is because
  366. the compilers do not have flags that can change the architecture,
  367. but rather depend on which compiler is being used
  368. */
  369. #if defined(_WIN32) && defined(_MSC_VER)
  370. # if defined(_M_IA64)
  371. # define ARCHITECTURE_ID "IA64"
  372. # elif defined(_M_X64) || defined(_M_AMD64)
  373. # define ARCHITECTURE_ID "x64"
  374. # elif defined(_M_IX86)
  375. # define ARCHITECTURE_ID "X86"
  376. # elif defined(_M_ARM64)
  377. # define ARCHITECTURE_ID "ARM64"
  378. # elif defined(_M_ARM)
  379. # if _M_ARM == 4
  380. # define ARCHITECTURE_ID "ARMV4I"
  381. # elif _M_ARM == 5
  382. # define ARCHITECTURE_ID "ARMV5I"
  383. # else
  384. # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM)
  385. # endif
  386. # elif defined(_M_MIPS)
  387. # define ARCHITECTURE_ID "MIPS"
  388. # elif defined(_M_SH)
  389. # define ARCHITECTURE_ID "SHx"
  390. # else /* unknown architecture */
  391. # define ARCHITECTURE_ID ""
  392. # endif
  393. #elif defined(__WATCOMC__)
  394. # if defined(_M_I86)
  395. # define ARCHITECTURE_ID "I86"
  396. # elif defined(_M_IX86)
  397. # define ARCHITECTURE_ID "X86"
  398. # else /* unknown architecture */
  399. # define ARCHITECTURE_ID ""
  400. # endif
  401. #elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC)
  402. # if defined(__ICCARM__)
  403. # define ARCHITECTURE_ID "ARM"
  404. # elif defined(__ICCRX__)
  405. # define ARCHITECTURE_ID "RX"
  406. # elif defined(__ICCRH850__)
  407. # define ARCHITECTURE_ID "RH850"
  408. # elif defined(__ICCRL78__)
  409. # define ARCHITECTURE_ID "RL78"
  410. # elif defined(__ICCRISCV__)
  411. # define ARCHITECTURE_ID "RISCV"
  412. # elif defined(__ICCAVR__)
  413. # define ARCHITECTURE_ID "AVR"
  414. # elif defined(__ICC430__)
  415. # define ARCHITECTURE_ID "MSP430"
  416. # else /* unknown architecture */
  417. # define ARCHITECTURE_ID ""
  418. # endif
  419. #elif defined(__ghs__)
  420. # if defined(__PPC64__)
  421. # define ARCHITECTURE_ID "PPC64"
  422. # elif defined(__ppc__)
  423. # define ARCHITECTURE_ID "PPC"
  424. # elif defined(__ARM__)
  425. # define ARCHITECTURE_ID "ARM"
  426. # elif defined(__x86_64__)
  427. # define ARCHITECTURE_ID "x64"
  428. # elif defined(__i386__)
  429. # define ARCHITECTURE_ID "X86"
  430. # else /* unknown architecture */
  431. # define ARCHITECTURE_ID ""
  432. # endif
  433. #else
  434. # define ARCHITECTURE_ID
  435. #endif
  436. /* Convert integer to decimal digit literals. */
  437. #define DEC(n) \
  438. ('0' + (((n) / 10000000)%10)), \
  439. ('0' + (((n) / 1000000)%10)), \
  440. ('0' + (((n) / 100000)%10)), \
  441. ('0' + (((n) / 10000)%10)), \
  442. ('0' + (((n) / 1000)%10)), \
  443. ('0' + (((n) / 100)%10)), \
  444. ('0' + (((n) / 10)%10)), \
  445. ('0' + ((n) % 10))
  446. /* Convert integer to hex digit literals. */
  447. #define HEX(n) \
  448. ('0' + ((n)>>28 & 0xF)), \
  449. ('0' + ((n)>>24 & 0xF)), \
  450. ('0' + ((n)>>20 & 0xF)), \
  451. ('0' + ((n)>>16 & 0xF)), \
  452. ('0' + ((n)>>12 & 0xF)), \
  453. ('0' + ((n)>>8 & 0xF)), \
  454. ('0' + ((n)>>4 & 0xF)), \
  455. ('0' + ((n) & 0xF))
  456. /* Construct a string literal encoding the version number components. */
  457. #ifdef COMPILER_VERSION_MAJOR
  458. char const info_version[] = {
  459. 'I', 'N', 'F', 'O', ':',
  460. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
  461. COMPILER_VERSION_MAJOR,
  462. # ifdef COMPILER_VERSION_MINOR
  463. '.', COMPILER_VERSION_MINOR,
  464. # ifdef COMPILER_VERSION_PATCH
  465. '.', COMPILER_VERSION_PATCH,
  466. # ifdef COMPILER_VERSION_TWEAK
  467. '.', COMPILER_VERSION_TWEAK,
  468. # endif
  469. # endif
  470. # endif
  471. ']','\0'};
  472. #endif
  473. /* Construct a string literal encoding the internal version number. */
  474. #ifdef COMPILER_VERSION_INTERNAL
  475. char const info_version_internal[] = {
  476. 'I', 'N', 'F', 'O', ':',
  477. 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_',
  478. 'i','n','t','e','r','n','a','l','[',
  479. COMPILER_VERSION_INTERNAL,']','\0'};
  480. #endif
  481. /* Construct a string literal encoding the version number components. */
  482. #ifdef SIMULATE_VERSION_MAJOR
  483. char const info_simulate_version[] = {
  484. 'I', 'N', 'F', 'O', ':',
  485. 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[',
  486. SIMULATE_VERSION_MAJOR,
  487. # ifdef SIMULATE_VERSION_MINOR
  488. '.', SIMULATE_VERSION_MINOR,
  489. # ifdef SIMULATE_VERSION_PATCH
  490. '.', SIMULATE_VERSION_PATCH,
  491. # ifdef SIMULATE_VERSION_TWEAK
  492. '.', SIMULATE_VERSION_TWEAK,
  493. # endif
  494. # endif
  495. # endif
  496. ']','\0'};
  497. #endif
  498. /* Construct the string literal in pieces to prevent the source from
  499. getting matched. Store it in a pointer rather than an array
  500. because some compilers will just produce instructions to fill the
  501. array rather than assigning a pointer to a static array. */
  502. char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
  503. char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
  504. #if !defined(__STDC__)
  505. # if (defined(_MSC_VER) && !defined(__clang__)) \
  506. || (defined(__ibmxl__) || defined(__IBMC__))
  507. # define C_DIALECT "90"
  508. # else
  509. # define C_DIALECT
  510. # endif
  511. #elif __STDC_VERSION__ >= 201000L
  512. # define C_DIALECT "11"
  513. #elif __STDC_VERSION__ >= 199901L
  514. # define C_DIALECT "99"
  515. #else
  516. # define C_DIALECT "90"
  517. #endif
  518. const char* info_language_dialect_default =
  519. "INFO" ":" "dialect_default[" C_DIALECT "]";
  520. /*--------------------------------------------------------------------------*/
  521. #ifdef ID_VOID_MAIN
  522. void main() {}
  523. #else
  524. # if defined(__CLASSIC_C__)
  525. int main(argc, argv) int argc; char *argv[];
  526. # else
  527. int main(int argc, char* argv[])
  528. # endif
  529. {
  530. int require = 0;
  531. require += info_compiler[argc];
  532. require += info_platform[argc];
  533. require += info_arch[argc];
  534. #ifdef COMPILER_VERSION_MAJOR
  535. require += info_version[argc];
  536. #endif
  537. #ifdef COMPILER_VERSION_INTERNAL
  538. require += info_version_internal[argc];
  539. #endif
  540. #ifdef SIMULATE_ID
  541. require += info_simulate[argc];
  542. #endif
  543. #ifdef SIMULATE_VERSION_MAJOR
  544. require += info_simulate_version[argc];
  545. #endif
  546. #if defined(__CRAYXE) || defined(__CRAYXC)
  547. require += info_cray[argc];
  548. #endif
  549. require += info_language_dialect_default[argc];
  550. (void)argv;
  551. return require;
  552. }
  553. #endif