CMakeCCompilerId.c 23 KB

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