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 /* IAR Systems compiler for embedded systems.
165 http://www.iar.com */
166 #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
167 # define COMPILER_ID "IAR"
169 #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
170 # define COMPILER_ID "MIPSpro"
171 # if defined(_SGI_COMPILER_VERSION)
172 /* _SGI_COMPILER_VERSION = VRP */
173 # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
174 # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
175 # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
177 /* _COMPILER_VERSION = VRP */
178 # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
179 # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
180 # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
183 /* This compiler is either not known or is too old to define an
184 identification macro. Try to identify the platform and guess that
185 it is the native compiler. */
187 # define COMPILER_ID "MIPSpro"
189 #elif defined(__hpux) || defined(__hpua)
190 # define COMPILER_ID "HP"
192 #else /* unknown compiler */
193 # define COMPILER_ID ""
197 /* Construct the string literal in pieces to prevent the source from
198 getting matched. Store it in a pointer rather than an array
199 because some compilers will just produce instructions to fill the
200 array rather than assigning a pointer to a static array. */
201 char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
203 /* Identify known platforms by name. */
204 #if defined(__linux) || defined(__linux__) || defined(linux)
205 # define PLATFORM_ID "Linux"
207 #elif defined(__CYGWIN__)
208 # define PLATFORM_ID "Cygwin"
210 #elif defined(__MINGW32__)
211 # define PLATFORM_ID "MinGW"
213 #elif defined(__APPLE__)
214 # define PLATFORM_ID "Darwin"
216 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
217 # define PLATFORM_ID "Windows"
219 #elif defined(__FreeBSD__) || defined(__FreeBSD)
220 # define PLATFORM_ID "FreeBSD"
222 #elif defined(__NetBSD__) || defined(__NetBSD)
223 # define PLATFORM_ID "NetBSD"
225 #elif defined(__OpenBSD__) || defined(__OPENBSD)
226 # define PLATFORM_ID "OpenBSD"
228 #elif defined(__sun) || defined(sun)
229 # define PLATFORM_ID "SunOS"
231 #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
232 # define PLATFORM_ID "AIX"
234 #elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
235 # define PLATFORM_ID "IRIX"
237 #elif defined(__hpux) || defined(__hpux__)
238 # define PLATFORM_ID "HP-UX"
240 #elif defined(__HAIKU__)
241 # define PLATFORM_ID "Haiku"
243 #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
244 # define PLATFORM_ID "BeOS"
246 #elif defined(__QNX__) || defined(__QNXNTO__)
247 # define PLATFORM_ID "QNX"
249 #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
250 # define PLATFORM_ID "Tru64"
252 #elif defined(__riscos) || defined(__riscos__)
253 # define PLATFORM_ID "RISCos"
255 #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
256 # define PLATFORM_ID "SINIX"
258 #elif defined(__UNIX_SV__)
259 # define PLATFORM_ID "UNIX_SV"
261 #elif defined(__bsdos__)
262 # define PLATFORM_ID "BSDOS"
264 #elif defined(_MPRAS) || defined(MPRAS)
265 # define PLATFORM_ID "MP-RAS"
267 #elif defined(__osf) || defined(__osf__)
268 # define PLATFORM_ID "OSF1"
270 #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
271 # define PLATFORM_ID "SCO_SV"
273 #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
274 # define PLATFORM_ID "ULTRIX"
276 #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
277 # define PLATFORM_ID "Xenix"
279 #else /* unknown platform */
280 # define PLATFORM_ID ""
284 /* For windows compilers MSVC and Intel we can determine
285 the architecture of the compiler being used. This is because
286 the compilers do not have flags that can change the architecture,
287 but rather depend on which compiler is being used
289 #if defined(_WIN32) && defined(_MSC_VER)
290 # if defined(_M_IA64)
291 # define ARCHITECTURE_ID "IA64"
293 # elif defined(_M_X64) || defined(_M_AMD64)
294 # define ARCHITECTURE_ID "x64"
296 # elif defined(_M_IX86)
297 # define ARCHITECTURE_ID "X86"
299 # elif defined(_M_ARM)
300 # define ARCHITECTURE_ID "ARM"
302 # elif defined(_M_MIPS)
303 # define ARCHITECTURE_ID "MIPS"
305 # elif defined(_M_SH)
306 # define ARCHITECTURE_ID "SHx"
308 # else /* unknown architecture */
309 # define ARCHITECTURE_ID ""
313 # define ARCHITECTURE_ID ""
316 /* Convert integer to decimal digit literals. */
318 ('0' + (((n) / 10000000)%10)), \
319 ('0' + (((n) / 1000000)%10)), \
320 ('0' + (((n) / 100000)%10)), \
321 ('0' + (((n) / 10000)%10)), \
322 ('0' + (((n) / 1000)%10)), \
323 ('0' + (((n) / 100)%10)), \
324 ('0' + (((n) / 10)%10)), \
327 /* Convert integer to hex digit literals. */
329 ('0' + ((n)>>28 & 0xF)), \
330 ('0' + ((n)>>24 & 0xF)), \
331 ('0' + ((n)>>20 & 0xF)), \
332 ('0' + ((n)>>16 & 0xF)), \
333 ('0' + ((n)>>12 & 0xF)), \
334 ('0' + ((n)>>8 & 0xF)), \
335 ('0' + ((n)>>4 & 0xF)), \
338 /* Construct a string literal encoding the version number components. */
339 #ifdef COMPILER_VERSION_MAJOR
340 char const info_version[] = {
341 'I', 'N', 'F', 'O', ':',
342 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[',
343 COMPILER_VERSION_MAJOR,
344 # ifdef COMPILER_VERSION_MINOR
345 '.', COMPILER_VERSION_MINOR,
346 # ifdef COMPILER_VERSION_PATCH
347 '.', COMPILER_VERSION_PATCH,
348 # ifdef COMPILER_VERSION_TWEAK
349 '.', COMPILER_VERSION_TWEAK,
356 /* Construct the string literal in pieces to prevent the source from
357 getting matched. Store it in a pointer rather than an array
358 because some compilers will just produce instructions to fill the
359 array rather than assigning a pointer to a static array. */
360 char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]";
361 char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]";
365 /*--------------------------------------------------------------------------*/
367 int main(int argc, char* argv[])
370 require += info_compiler[argc];
371 require += info_platform[argc];
372 #ifdef COMPILER_VERSION_MAJOR
373 require += info_version[argc];