CMakeCCompilerId.c.in 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #if !defined(__has_include)
  13. /* If the compiler does not have __has_include, pretend the answer is
  14. always no. */
  15. # define __has_include(x) 0
  16. #endif
  17. @CMAKE_C_COMPILER_ID_CONTENT@
  18. /* Construct the string literal in pieces to prevent the source from
  19. getting matched. Store it in a pointer rather than an array
  20. because some compilers will just produce instructions to fill the
  21. array rather than assigning a pointer to a static array. */
  22. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  23. #ifdef SIMULATE_ID
  24. char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
  25. #endif
  26. #ifdef __QNXNTO__
  27. char const* qnxnto = "INFO" ":" "qnxnto[]";
  28. #endif
  29. #if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
  30. char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]";
  31. #endif
  32. @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
  33. @CMAKE_C_COMPILER_ID_ERROR_FOR_TEST@
  34. #if !defined(__STDC__) && !defined(__clang__)
  35. # if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__)
  36. # define C_VERSION "90"
  37. # else
  38. # define C_VERSION
  39. # endif
  40. #elif __STDC_VERSION__ > 201710L
  41. # define C_VERSION "23"
  42. #elif __STDC_VERSION__ >= 201710L
  43. # define C_VERSION "17"
  44. #elif __STDC_VERSION__ >= 201000L
  45. # define C_VERSION "11"
  46. #elif __STDC_VERSION__ >= 199901L
  47. # define C_VERSION "99"
  48. #else
  49. # define C_VERSION "90"
  50. #endif
  51. const char* info_language_standard_default =
  52. "INFO" ":" "standard_default[" C_VERSION "]";
  53. const char* info_language_extensions_default = "INFO" ":" "extensions_default["
  54. // !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode.
  55. #if (defined(__clang__) || defined(__GNUC__) || \
  56. defined(__TI_COMPILER_VERSION__)) && \
  57. !defined(__STRICT_ANSI__) && !defined(_MSC_VER)
  58. "ON"
  59. #else
  60. "OFF"
  61. #endif
  62. "]";
  63. /*--------------------------------------------------------------------------*/
  64. #ifdef ID_VOID_MAIN
  65. void main() {}
  66. #else
  67. # if defined(__CLASSIC_C__)
  68. int main(argc, argv) int argc; char *argv[];
  69. # else
  70. int main(int argc, char* argv[])
  71. # endif
  72. {
  73. int require = 0;
  74. require += info_compiler[argc];
  75. require += info_platform[argc];
  76. require += info_arch[argc];
  77. #ifdef COMPILER_VERSION_MAJOR
  78. require += info_version[argc];
  79. #endif
  80. #ifdef COMPILER_VERSION_INTERNAL
  81. require += info_version_internal[argc];
  82. #endif
  83. #ifdef SIMULATE_ID
  84. require += info_simulate[argc];
  85. #endif
  86. #ifdef SIMULATE_VERSION_MAJOR
  87. require += info_simulate_version[argc];
  88. #endif
  89. #if defined(__CRAYXT_COMPUTE_LINUX_TARGET)
  90. require += info_cray[argc];
  91. #endif
  92. require += info_language_standard_default[argc];
  93. require += info_language_extensions_default[argc];
  94. (void)argv;
  95. return require;
  96. }
  97. #endif