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