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