LibTgBotPP
 All Classes Namespaces Files Functions Variables Typedefs Macros
CMakeCCompilerId.c
Go to the documentation of this file.
1 #ifdef __cplusplus
2 # error "A C++ compiler has been selected for C."
3 #endif
4 
5 /* Version number components: V=Version, R=Revision, P=Patch
6  Version date components: YYYY=Year, MM=Month, DD=Day */
7 
8 #if defined(__18CXX)
9 # define ID_VOID_MAIN
10 #endif
11 
12 #if defined(__INTEL_COMPILER) || defined(__ICC)
13 # define COMPILER_ID "Intel"
14  /* __INTEL_COMPILER = VRP */
15 # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
16 # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
17 # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
18 # if defined(__INTEL_COMPILER_BUILD_DATE)
19  /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
20 # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
21 # endif
22 
23 #elif defined(__PATHCC__)
24 # define COMPILER_ID "PathScale"
25 # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
26 # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
27 # if defined(__PATHCC_PATCHLEVEL__)
28 # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
29 # endif
30 
31 #elif defined(__clang__)
32 # define COMPILER_ID "Clang"
33 # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
34 # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
35 # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
36 
37 #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
38 # define COMPILER_ID "Embarcadero"
39 # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
40 # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
41 # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)
42 
43 #elif defined(__BORLANDC__)
44 # define COMPILER_ID "Borland"
45  /* __BORLANDC__ = 0xVRR */
46 # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
47 # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
48 
49 #elif defined(__WATCOMC__)
50 # define COMPILER_ID "Watcom"
51  /* __WATCOMC__ = VVRR */
52 # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
53 # define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
54 
55 #elif defined(__SUNPRO_C)
56 # define COMPILER_ID "SunPro"
57 # if __SUNPRO_C >= 0x5100
58  /* __SUNPRO_C = 0xVRRP */
59 # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
60 # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
61 # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
62 # else
63  /* __SUNPRO_C = 0xVRP */
64 # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
65 # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
66 # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
67 # endif
68 
69 #elif defined(__HP_cc)
70 # define COMPILER_ID "HP"
71  /* __HP_cc = VVRRPP */
72 # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
73 # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
74 # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
75 
76 #elif defined(__DECC)
77 # define COMPILER_ID "Compaq"
78  /* __DECC_VER = VVRRTPPPP */
79 # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
80 # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
81 # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
82 
83 #elif defined(__IBMC__)
84 # if defined(__COMPILER_VER__)
85 # define COMPILER_ID "zOS"
86 # else
87 # if __IBMC__ >= 800
88 # define COMPILER_ID "XL"
89 # else
90 # define COMPILER_ID "VisualAge"
91 # endif
92  /* __IBMC__ = VRP */
93 # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
94 # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
95 # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
96 # endif
97 
98 #elif defined(__PGI)
99 # define COMPILER_ID "PGI"
100 # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
101 # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
102 # if defined(__PGIC_PATCHLEVEL__)
103 # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
104 # endif
105 
106 #elif defined(_CRAYC)
107 # define COMPILER_ID "Cray"
108 # define COMPILER_VERSION_MAJOR DEC(_RELEASE)
109 # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
110 
111 #elif defined(__TI_COMPILER_VERSION__)
112 # define COMPILER_ID "TI"
113  /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
114 # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
115 # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
116 # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
117 
118 #elif defined(__TINYC__)
119 # define COMPILER_ID "TinyCC"
120 
121 #elif defined(__SCO_VERSION__)
122 # define COMPILER_ID "SCO"
123 
124 #elif defined(__GNUC__)
125 # define COMPILER_ID "GNU"
126 # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
127 # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
128 # if defined(__GNUC_PATCHLEVEL__)
129 # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
130 # endif
131 
132 #elif defined(_MSC_VER)
133 # define COMPILER_ID "MSVC"
134  /* _MSC_VER = VVRR */
135 # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
136 # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
137 # if defined(_MSC_FULL_VER)
138 # if _MSC_VER >= 1400
139  /* _MSC_FULL_VER = VVRRPPPPP */
140 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
141 # else
142  /* _MSC_FULL_VER = VVRRPPPP */
143 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
144 # endif
145 # endif
146 # if defined(_MSC_BUILD)
147 # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
148 # endif
149 
150 /* Analog VisualDSP++ >= 4.5.6 */
151 #elif defined(__VISUALDSPVERSION__)
152 # define COMPILER_ID "ADSP"
153  /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
154 # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
155 # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
156 # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
157 
158 /* Analog VisualDSP++ < 4.5.6 */
159 #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
160 # define COMPILER_ID "ADSP"
161 
162 /* IAR Systems compiler for embedded systems.
163  http://www.iar.com */
164 #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
165 # define COMPILER_ID "IAR"
166 
167 /* sdcc, the small devices C compiler for embedded systems,
168  http://sdcc.sourceforge.net */
169 #elif defined(SDCC)
170 # define COMPILER_ID "SDCC"
171  /* SDCC = VRP */
172 # define COMPILER_VERSION_MAJOR DEC(SDCC/100)
173 # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
174 # define COMPILER_VERSION_PATCH DEC(SDCC % 10)
175 
176 #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
177 # define COMPILER_ID "MIPSpro"
178 # if defined(_SGI_COMPILER_VERSION)
179  /* _SGI_COMPILER_VERSION = VRP */
180 # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
181 # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
182 # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
183 # else
184  /* _COMPILER_VERSION = VRP */
185 # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
186 # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
187 # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
188 # endif
189 
190 /* This compiler is either not known or is too old to define an
191  identification macro. Try to identify the platform and guess that
192  it is the native compiler. */
193 #elif defined(__sgi)
194 # define COMPILER_ID "MIPSpro"
195 
196 #elif defined(__hpux) || defined(__hpua)
197 # define COMPILER_ID "HP"
198 
199 #else /* unknown compiler */
200 # define COMPILER_ID ""
201 
202 #endif
203 
204 /* Construct the string literal in pieces to prevent the source from
205  getting matched. Store it in a pointer rather than an array
206  because some compilers will just produce instructions to fill the
207  array rather than assigning a pointer to a static array. */
208 char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
209 
210 /* Identify known platforms by name. */
211 #if defined(__linux) || defined(__linux__) || defined(linux)
212 # define PLATFORM_ID "Linux"
213 
214 #elif defined(__CYGWIN__)
215 # define PLATFORM_ID "Cygwin"
216 
217 #elif defined(__MINGW32__)
218 # define PLATFORM_ID "MinGW"
219 
220 #elif defined(__APPLE__)
221 # define PLATFORM_ID "Darwin"
222 
223 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
224 # define PLATFORM_ID "Windows"
225 
226 #elif defined(__FreeBSD__) || defined(__FreeBSD)
227 # define PLATFORM_ID "FreeBSD"
228 
229 #elif defined(__NetBSD__) || defined(__NetBSD)
230 # define PLATFORM_ID "NetBSD"
231 
232 #elif defined(__OpenBSD__) || defined(__OPENBSD)
233 # define PLATFORM_ID "OpenBSD"
234 
235 #elif defined(__sun) || defined(sun)
236 # define PLATFORM_ID "SunOS"
237 
238 #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
239 # define PLATFORM_ID "AIX"
240 
241 #elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
242 # define PLATFORM_ID "IRIX"
243 
244 #elif defined(__hpux) || defined(__hpux__)
245 # define PLATFORM_ID "HP-UX"
246 
247 #elif defined(__HAIKU__)
248 # define PLATFORM_ID "Haiku"
249 
250 #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
251 # define PLATFORM_ID "BeOS"
252 
253 #elif defined(__QNX__) || defined(__QNXNTO__)
254 # define PLATFORM_ID "QNX"
255 
256 #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
257 # define PLATFORM_ID "Tru64"
258 
259 #elif defined(__riscos) || defined(__riscos__)
260 # define PLATFORM_ID "RISCos"
261 
262 #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
263 # define PLATFORM_ID "SINIX"
264 
265 #elif defined(__UNIX_SV__)
266 # define PLATFORM_ID "UNIX_SV"
267 
268 #elif defined(__bsdos__)
269 # define PLATFORM_ID "BSDOS"
270 
271 #elif defined(_MPRAS) || defined(MPRAS)
272 # define PLATFORM_ID "MP-RAS"
273 
274 #elif defined(__osf) || defined(__osf__)
275 # define PLATFORM_ID "OSF1"
276 
277 #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
278 # define PLATFORM_ID "SCO_SV"
279 
280 #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
281 # define PLATFORM_ID "ULTRIX"
282 
283 #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
284 # define PLATFORM_ID "Xenix"
285 
286 #else /* unknown platform */
287 # define PLATFORM_ID ""
288 
289 #endif
290 
291 /* For windows compilers MSVC and Intel we can determine
292  the architecture of the compiler being used. This is because
293  the compilers do not have flags that can change the architecture,
294  but rather depend on which compiler is being used
295 */
296 #if defined(_WIN32) && defined(_MSC_VER)
297 # if defined(_M_IA64)
298 # define ARCHITECTURE_ID "IA64"
299 
300 # elif defined(_M_X64) || defined(_M_AMD64)
301 # define ARCHITECTURE_ID "x64"
302 
303 # elif defined(_M_IX86)
304 # define ARCHITECTURE_ID "X86"
305 
306 # elif defined(_M_ARM)
307 # define ARCHITECTURE_ID "ARM"
308 
309 # elif defined(_M_MIPS)
310 # define ARCHITECTURE_ID "MIPS"
311 
312 # elif defined(_M_SH)
313 # define ARCHITECTURE_ID "SHx"
314 
315 # else /* unknown architecture */
316 # define ARCHITECTURE_ID ""
317 # endif
318 
319 #else
320 # define ARCHITECTURE_ID ""
321 #endif
322 
323 /* Convert integer to decimal digit literals. */
324 #define DEC(n) \
325  ('0' + (((n) / 10000000)%10)), \
326  ('0' + (((n) / 1000000)%10)), \
327  ('0' + (((n) / 100000)%10)), \
328  ('0' + (((n) / 10000)%10)), \
329  ('0' + (((n) / 1000)%10)), \
330  ('0' + (((n) / 100)%10)), \
331  ('0' + (((n) / 10)%10)), \
332  ('0' + ((n) % 10))
333 
334 /* Convert integer to hex digit literals. */
335 #define HEX(n) \
336  ('0' + ((n)>>28 & 0xF)), \
337  ('0' + ((n)>>24 & 0xF)), \
338  ('0' + ((n)>>20 & 0xF)), \
339  ('0' + ((n)>>16 & 0xF)), \
340  ('0' + ((n)>>12 & 0xF)), \
341  ('0' + ((n)>>8 & 0xF)), \
342  ('0' + ((n)>>4 & 0xF)), \
343  ('0' + ((n) & 0xF))
344 
345 /* Construct a string literal encoding the version number components. */
346 #ifdef COMPILER_VERSION_MAJOR
347 char const info_version[] = {
348  'I', 'N', 'F', 'O', ':',
349  'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
350  COMPILER_VERSION_MAJOR,
351 # ifdef COMPILER_VERSION_MINOR
352  '.', COMPILER_VERSION_MINOR,
353 # ifdef COMPILER_VERSION_PATCH
354  '.', COMPILER_VERSION_PATCH,
355 # ifdef COMPILER_VERSION_TWEAK
356  '.', COMPILER_VERSION_TWEAK,
357 # endif
358 # endif
359 # endif
360  ']','\0'};
361 #endif
362 
363 /* Construct the string literal in pieces to prevent the source from
364  getting matched. Store it in a pointer rather than an array
365  because some compilers will just produce instructions to fill the
366  array rather than assigning a pointer to a static array. */
367 char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
368 char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
369 
370 
371 
372 /*--------------------------------------------------------------------------*/
373 
374 #ifdef ID_VOID_MAIN
375 void main() {}
376 #else
377 int main(int argc, char* argv[])
378 {
379  int require = 0;
380  require += info_compiler[argc];
381  require += info_platform[argc];
382  require += info_arch[argc];
383 #ifdef COMPILER_VERSION_MAJOR
384  require += info_version[argc];
385 #endif
386  (void)argv;
387  return require;
388 }
389 #endif
char const * info_arch
char const * info_compiler
int main(int argc, char *argv[])
char const * info_platform
#define ARCHITECTURE_ID
#define COMPILER_ID
#define PLATFORM_ID