説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

CMakeCXXCompilerId.cpp 24KB

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