1
/* This source file must have a .cpp extension so that all C++ compilers
2
recognize the extension without flags. Borland does not know .cxx for
5
# error "A C compiler has been selected for C++."
8
/* Version number components: V=Version, R=Revision, P=Patch
9
Version date components: YYYY=Year, MM=Month, DD=Day */
12
# define COMPILER_ID "Comeau"
13
/* __COMO_VERSION__ = VRR */
14
# define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
15
# define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
17
#elif defined(__INTEL_COMPILER) || defined(__ICC)
18
# define COMPILER_ID "Intel"
19
/* __INTEL_COMPILER = VRP */
20
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
21
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
22
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
23
# if defined(__INTEL_COMPILER_BUILD_DATE)
24
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
25
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
28
#elif defined(__PATHCC__)
29
# define COMPILER_ID "PathScale"
30
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
31
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
32
# if defined(__PATHCC_PATCHLEVEL__)
33
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
36
#elif defined(__clang__)
37
# define COMPILER_ID "Clang"
38
# define COMPILER_VERSION_MAJOR DEC(__clang_major__)
39
# define COMPILER_VERSION_MINOR DEC(__clang_minor__)
40
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
42
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
43
# define COMPILER_ID "Embarcadero"
44
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
45
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
46
# define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)
48
#elif defined(__BORLANDC__)
49
# define COMPILER_ID "Borland"
50
/* __BORLANDC__ = 0xVRR */
51
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
52
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
54
#elif defined(__WATCOMC__)
55
# define COMPILER_ID "Watcom"
56
/* __WATCOMC__ = VVRR */
57
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
58
# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
60
#elif defined(__SUNPRO_CC)
61
# define COMPILER_ID "SunPro"
62
# if __SUNPRO_CC >= 0x5100
63
/* __SUNPRO_CC = 0xVRRP */
64
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
65
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
66
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
68
/* __SUNPRO_CC = 0xVRP */
69
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
70
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
71
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
74
#elif defined(__HP_aCC)
75
# define COMPILER_ID "HP"
76
/* __HP_aCC = VVRRPP */
77
# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
78
# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
79
# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
81
#elif defined(__DECCXX)
82
# define COMPILER_ID "Compaq"
83
/* __DECCXX_VER = VVRRTPPPP */
84
# define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
85
# define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
86
# define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
88
#elif defined(__IBMCPP__)
89
# if defined(__COMPILER_VER__)
90
# define COMPILER_ID "zOS"
92
# if __IBMCPP__ >= 800
93
# define COMPILER_ID "XL"
95
# define COMPILER_ID "VisualAge"
97
/* __IBMCPP__ = VRP */
98
# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
99
# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
100
# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
104
# define COMPILER_ID "PGI"
105
# define COMPILER_VERSION_MAJOR DEC(__PGIC__)
106
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
107
# if defined(__PGIC_PATCHLEVEL__)
108
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
111
#elif defined(_CRAYC)
112
# define COMPILER_ID "Cray"
113
# define COMPILER_VERSION_MAJOR DEC(_RELEASE)
114
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
116
#elif defined(__TI_COMPILER_VERSION__)
117
# define COMPILER_ID "TI"
118
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */
119
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
120
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
121
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
123
#elif defined(__SCO_VERSION__)
124
# define COMPILER_ID "SCO"
126
#elif defined(__GNUC__)
127
# define COMPILER_ID "GNU"
128
# define COMPILER_VERSION_MAJOR DEC(__GNUC__)
129
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
130
# if defined(__GNUC_PATCHLEVEL__)
131
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
134
#elif defined(_MSC_VER)
135
# define COMPILER_ID "MSVC"
136
/* _MSC_VER = VVRR */
137
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
138
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
139
# if defined(_MSC_FULL_VER)
140
# if _MSC_VER >= 1400
141
/* _MSC_FULL_VER = VVRRPPPPP */
142
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
144
/* _MSC_FULL_VER = VVRRPPPP */
145
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
148
# if defined(_MSC_BUILD)
149
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
152
/* Analog VisualDSP++ >= 4.5.6 */
153
#elif defined(__VISUALDSPVERSION__)
154
# define COMPILER_ID "ADSP"
155
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */
156
# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
157
# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
158
# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
160
/* Analog VisualDSP++ < 4.5.6 */
161
#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
162
# define COMPILER_ID "ADSP"
164
#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
165
# define COMPILER_ID "MIPSpro"
166
# if defined(_SGI_COMPILER_VERSION)
167
/* _SGI_COMPILER_VERSION = VRP */
168
# define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
169
# define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
170
# define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
172
/* _COMPILER_VERSION = VRP */
173
# define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
174
# define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
175
# define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
178
/* This compiler is either not known or is too old to define an
179
identification macro. Try to identify the platform and guess that
180
it is the native compiler. */
182
# define COMPILER_ID "MIPSpro"
184
#elif defined(__hpux) || defined(__hpua)
185
# define COMPILER_ID "HP"
187
#else /* unknown compiler */
188
# define COMPILER_ID ""
192
/* Construct the string literal in pieces to prevent the source from
193
getting matched. Store it in a pointer rather than an array
194
because some compilers will just produce instructions to fill the
195
array rather than assigning a pointer to a static array. */
196
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
198
/* Identify known platforms by name. */
199
#if defined(__linux) || defined(__linux__) || defined(linux)
200
# define PLATFORM_ID "Linux"
202
#elif defined(__CYGWIN__)
203
# define PLATFORM_ID "Cygwin"
205
#elif defined(__MINGW32__)
206
# define PLATFORM_ID "MinGW"
208
#elif defined(__APPLE__)
209
# define PLATFORM_ID "Darwin"
211
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
212
# define PLATFORM_ID "Windows"
214
#elif defined(__FreeBSD__) || defined(__FreeBSD)
215
# define PLATFORM_ID "FreeBSD"
217
#elif defined(__NetBSD__) || defined(__NetBSD)
218
# define PLATFORM_ID "NetBSD"
220
#elif defined(__OpenBSD__) || defined(__OPENBSD)
221
# define PLATFORM_ID "OpenBSD"
223
#elif defined(__sun) || defined(sun)
224
# define PLATFORM_ID "SunOS"
226
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
227
# define PLATFORM_ID "AIX"
229
#elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
230
# define PLATFORM_ID "IRIX"
232
#elif defined(__hpux) || defined(__hpux__)
233
# define PLATFORM_ID "HP-UX"
235
#elif defined(__HAIKU__)
236
# define PLATFORM_ID "Haiku"
238
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
239
# define PLATFORM_ID "BeOS"
241
#elif defined(__QNX__) || defined(__QNXNTO__)
242
# define PLATFORM_ID "QNX"
244
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
245
# define PLATFORM_ID "Tru64"
247
#elif defined(__riscos) || defined(__riscos__)
248
# define PLATFORM_ID "RISCos"
250
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
251
# define PLATFORM_ID "SINIX"
253
#elif defined(__UNIX_SV__)
254
# define PLATFORM_ID "UNIX_SV"
256
#elif defined(__bsdos__)
257
# define PLATFORM_ID "BSDOS"
259
#elif defined(_MPRAS) || defined(MPRAS)
260
# define PLATFORM_ID "MP-RAS"
262
#elif defined(__osf) || defined(__osf__)
263
# define PLATFORM_ID "OSF1"
265
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
266
# define PLATFORM_ID "SCO_SV"
268
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
269
# define PLATFORM_ID "ULTRIX"
271
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
272
# define PLATFORM_ID "Xenix"
274
#else /* unknown platform */
275
# define PLATFORM_ID ""
279
/* For windows compilers MSVC and Intel we can determine
280
the architecture of the compiler being used. This is because
281
the compilers do not have flags that can change the architecture,
282
but rather depend on which compiler is being used
284
#if defined(_WIN32) && defined(_MSC_VER)
285
# if defined(_M_IA64)
286
# define ARCHITECTURE_ID "IA64"
288
# elif defined(_M_X64) || defined(_M_AMD64)
289
# define ARCHITECTURE_ID "x64"
291
# elif defined(_M_IX86)
292
# define ARCHITECTURE_ID "X86"
294
# elif defined(_M_ARM)
295
# define ARCHITECTURE_ID "ARM"
297
# elif defined(_M_MIPS)
298
# define ARCHITECTURE_ID "MIPS"
300
# elif defined(_M_SH)
301
# define ARCHITECTURE_ID "SHx"
303
# else /* unknown architecture */
304
# define ARCHITECTURE_ID ""
308
# define ARCHITECTURE_ID ""
311
/* Convert integer to decimal digit literals. */
313
('0' + (((n) / 10000000)%10)), \
314
('0' + (((n) / 1000000)%10)), \
315
('0' + (((n) / 100000)%10)), \
316
('0' + (((n) / 10000)%10)), \
317
('0' + (((n) / 1000)%10)), \
318
('0' + (((n) / 100)%10)), \
319
('0' + (((n) / 10)%10)), \
322
/* Convert integer to hex digit literals. */
324
('0' + ((n)>>28 & 0xF)), \
325
('0' + ((n)>>24 & 0xF)), \
326
('0' + ((n)>>20 & 0xF)), \
327
('0' + ((n)>>16 & 0xF)), \
328
('0' + ((n)>>12 & 0xF)), \
329
('0' + ((n)>>8 & 0xF)), \
330
('0' + ((n)>>4 & 0xF)), \
333
/* Construct a string literal encoding the version number components. */
334
#ifdef COMPILER_VERSION_MAJOR
335
char const info_version[] = {
336
'I', 'N', 'F', 'O', ':',
337
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
338
COMPILER_VERSION_MAJOR,
339
# ifdef COMPILER_VERSION_MINOR
340
'.', COMPILER_VERSION_MINOR,
341
# ifdef COMPILER_VERSION_PATCH
342
'.', COMPILER_VERSION_PATCH,
343
# ifdef COMPILER_VERSION_TWEAK
344
'.', COMPILER_VERSION_TWEAK,
351
/* Construct the string literal in pieces to prevent the source from
352
getting matched. Store it in a pointer rather than an array
353
because some compilers will just produce instructions to fill the
354
array rather than assigning a pointer to a static array. */
355
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
356
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
360
/*--------------------------------------------------------------------------*/
362
int main(int argc, char* argv[])
365
require += info_compiler[argc];
366
require += info_platform[argc];
367
#ifdef COMPILER_VERSION_MAJOR
368
require += info_version[argc];