CMakeCCompilerId.c 22 KB

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