2 # error "A C++ compiler has been selected for C."
5 /* Version number components: V=Version, R=Revision, P=Patch
6 Version date components: YYYY=Year, MM=Month, DD=Day */
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)
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__)
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__)
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)
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)
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)
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)
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)
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)
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)
83 #elif defined(__IBMC__)
84 # if defined(__COMPILER_VER__)
85 # define COMPILER_ID "zOS"
88 # define COMPILER_ID "XL"
90 # define COMPILER_ID "VisualAge"
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)
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__)
106 #elif defined(_CRAYC)
107 # define COMPILER_ID "Cray"
108 # define COMPILER_VERSION_MAJOR DEC(_RELEASE)
109 # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
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)
118 #elif defined(__TINYC__)
119 # define COMPILER_ID "TinyCC"
121 #elif defined(__SCO_VERSION__)
122 # define COMPILER_ID "SCO"
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__)
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)
142 /* _MSC_FULL_VER = VVRRPPPP */
143 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
146 # if defined(_MSC_BUILD)
147 # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
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)
158 /* Analog VisualDSP++ < 4.5.6 */
159 #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
160 # define COMPILER_ID "ADSP"
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"
167 /* sdcc, the small devices C compiler for embedded systems,
168 http://sdcc.sourceforge.net */
170 # define COMPILER_ID "SDCC"
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)
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)
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)
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. */
194 # define COMPILER_ID "MIPSpro"
196 #elif defined(__hpux) || defined(__hpua)
197 # define COMPILER_ID "HP"
199 #else /* unknown compiler */
200 # define COMPILER_ID ""
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 "]";
210 /* Identify known platforms by name. */
211 #if defined(__linux) || defined(__linux__) || defined(linux)
212 # define PLATFORM_ID "Linux"
214 #elif defined(__CYGWIN__)
215 # define PLATFORM_ID "Cygwin"
217 #elif defined(__MINGW32__)
218 # define PLATFORM_ID "MinGW"
220 #elif defined(__APPLE__)
221 # define PLATFORM_ID "Darwin"
223 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
224 # define PLATFORM_ID "Windows"
226 #elif defined(__FreeBSD__) || defined(__FreeBSD)
227 # define PLATFORM_ID "FreeBSD"
229 #elif defined(__NetBSD__) || defined(__NetBSD)
230 # define PLATFORM_ID "NetBSD"
232 #elif defined(__OpenBSD__) || defined(__OPENBSD)
233 # define PLATFORM_ID "OpenBSD"
235 #elif defined(__sun) || defined(sun)
236 # define PLATFORM_ID "SunOS"
238 #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
239 # define PLATFORM_ID "AIX"
241 #elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
242 # define PLATFORM_ID "IRIX"
244 #elif defined(__hpux) || defined(__hpux__)
245 # define PLATFORM_ID "HP-UX"
247 #elif defined(__HAIKU__)
248 # define PLATFORM_ID "Haiku"
250 #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
251 # define PLATFORM_ID "BeOS"
253 #elif defined(__QNX__) || defined(__QNXNTO__)
254 # define PLATFORM_ID "QNX"
256 #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
257 # define PLATFORM_ID "Tru64"
259 #elif defined(__riscos) || defined(__riscos__)
260 # define PLATFORM_ID "RISCos"
262 #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
263 # define PLATFORM_ID "SINIX"
265 #elif defined(__UNIX_SV__)
266 # define PLATFORM_ID "UNIX_SV"
268 #elif defined(__bsdos__)
269 # define PLATFORM_ID "BSDOS"
271 #elif defined(_MPRAS) || defined(MPRAS)
272 # define PLATFORM_ID "MP-RAS"
274 #elif defined(__osf) || defined(__osf__)
275 # define PLATFORM_ID "OSF1"
277 #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
278 # define PLATFORM_ID "SCO_SV"
280 #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
281 # define PLATFORM_ID "ULTRIX"
283 #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
284 # define PLATFORM_ID "Xenix"
286 #else /* unknown platform */
287 # define PLATFORM_ID ""
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
296 #if defined(_WIN32) && defined(_MSC_VER)
297 # if defined(_M_IA64)
298 # define ARCHITECTURE_ID "IA64"
300 # elif defined(_M_X64) || defined(_M_AMD64)
301 # define ARCHITECTURE_ID "x64"
303 # elif defined(_M_IX86)
304 # define ARCHITECTURE_ID "X86"
306 # elif defined(_M_ARM)
307 # define ARCHITECTURE_ID "ARM"
309 # elif defined(_M_MIPS)
310 # define ARCHITECTURE_ID "MIPS"
312 # elif defined(_M_SH)
313 # define ARCHITECTURE_ID "SHx"
315 # else /* unknown architecture */
316 # define ARCHITECTURE_ID ""
320 # define ARCHITECTURE_ID ""
323 /* Convert integer to decimal digit literals. */
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)), \
334 /* Convert integer to hex digit literals. */
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)), \
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,
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 "]";
372 /*--------------------------------------------------------------------------*/
377 int main(int argc, char* argv[])
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];