LibTgBotPP
 All Classes Namespaces Files Functions Variables Typedefs Macros
CMakeCXXCompilerId.cpp
Go to the documentation of this file.
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
3  example. */
4 #ifndef __cplusplus
5 # error "A C compiler has been selected for C++."
6 #endif
7 
8 /* Version number components: V=Version, R=Revision, P=Patch
9  Version date components: YYYY=Year, MM=Month, DD=Day */
10 
11 #if defined(__COMO__)
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)
16 
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)
26 # endif
27 
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__)
34 # endif
35 
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__)
41 
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)
47 
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)
53 
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)
59 
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)
67 # else
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)
72 # endif
73 
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)
80 
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)
87 
88 #elif defined(__IBMCPP__)
89 # if defined(__COMPILER_VER__)
90 # define COMPILER_ID "zOS"
91 # else
92 # if __IBMCPP__ >= 800
93 # define COMPILER_ID "XL"
94 # else
95 # define COMPILER_ID "VisualAge"
96 # endif
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)
101 # endif
102 
103 #elif defined(__PGI)
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__)
109 # endif
110 
111 #elif defined(_CRAYC)
112 # define COMPILER_ID "Cray"
113 # define COMPILER_VERSION_MAJOR DEC(_RELEASE)
114 # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
115 
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)
122 
123 #elif defined(__SCO_VERSION__)
124 # define COMPILER_ID "SCO"
125 
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__)
132 # endif
133 
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)
143 # else
144  /* _MSC_FULL_VER = VVRRPPPP */
145 # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
146 # endif
147 # endif
148 # if defined(_MSC_BUILD)
149 # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
150 # endif
151 
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)
159 
160 /* Analog VisualDSP++ < 4.5.6 */
161 #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
162 # define COMPILER_ID "ADSP"
163 
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"
168 
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)
176 # else
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)
181 # endif
182 
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. */
186 #elif defined(__sgi)
187 # define COMPILER_ID "MIPSpro"
188 
189 #elif defined(__hpux) || defined(__hpua)
190 # define COMPILER_ID "HP"
191 
192 #else /* unknown compiler */
193 # define COMPILER_ID ""
194 
195 #endif
196 
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 "]";
202 
203 /* Identify known platforms by name. */
204 #if defined(__linux) || defined(__linux__) || defined(linux)
205 # define PLATFORM_ID "Linux"
206 
207 #elif defined(__CYGWIN__)
208 # define PLATFORM_ID "Cygwin"
209 
210 #elif defined(__MINGW32__)
211 # define PLATFORM_ID "MinGW"
212 
213 #elif defined(__APPLE__)
214 # define PLATFORM_ID "Darwin"
215 
216 #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
217 # define PLATFORM_ID "Windows"
218 
219 #elif defined(__FreeBSD__) || defined(__FreeBSD)
220 # define PLATFORM_ID "FreeBSD"
221 
222 #elif defined(__NetBSD__) || defined(__NetBSD)
223 # define PLATFORM_ID "NetBSD"
224 
225 #elif defined(__OpenBSD__) || defined(__OPENBSD)
226 # define PLATFORM_ID "OpenBSD"
227 
228 #elif defined(__sun) || defined(sun)
229 # define PLATFORM_ID "SunOS"
230 
231 #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
232 # define PLATFORM_ID "AIX"
233 
234 #elif defined(__sgi) || defined(__sgi__) || defined(_SGI)
235 # define PLATFORM_ID "IRIX"
236 
237 #elif defined(__hpux) || defined(__hpux__)
238 # define PLATFORM_ID "HP-UX"
239 
240 #elif defined(__HAIKU__)
241 # define PLATFORM_ID "Haiku"
242 
243 #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS)
244 # define PLATFORM_ID "BeOS"
245 
246 #elif defined(__QNX__) || defined(__QNXNTO__)
247 # define PLATFORM_ID "QNX"
248 
249 #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__)
250 # define PLATFORM_ID "Tru64"
251 
252 #elif defined(__riscos) || defined(__riscos__)
253 # define PLATFORM_ID "RISCos"
254 
255 #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__)
256 # define PLATFORM_ID "SINIX"
257 
258 #elif defined(__UNIX_SV__)
259 # define PLATFORM_ID "UNIX_SV"
260 
261 #elif defined(__bsdos__)
262 # define PLATFORM_ID "BSDOS"
263 
264 #elif defined(_MPRAS) || defined(MPRAS)
265 # define PLATFORM_ID "MP-RAS"
266 
267 #elif defined(__osf) || defined(__osf__)
268 # define PLATFORM_ID "OSF1"
269 
270 #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv)
271 # define PLATFORM_ID "SCO_SV"
272 
273 #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX)
274 # define PLATFORM_ID "ULTRIX"
275 
276 #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
277 # define PLATFORM_ID "Xenix"
278 
279 #else /* unknown platform */
280 # define PLATFORM_ID ""
281 
282 #endif
283 
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
288 */
289 #if defined(_WIN32) && defined(_MSC_VER)
290 # if defined(_M_IA64)
291 # define ARCHITECTURE_ID "IA64"
292 
293 # elif defined(_M_X64) || defined(_M_AMD64)
294 # define ARCHITECTURE_ID "x64"
295 
296 # elif defined(_M_IX86)
297 # define ARCHITECTURE_ID "X86"
298 
299 # elif defined(_M_ARM)
300 # define ARCHITECTURE_ID "ARM"
301 
302 # elif defined(_M_MIPS)
303 # define ARCHITECTURE_ID "MIPS"
304 
305 # elif defined(_M_SH)
306 # define ARCHITECTURE_ID "SHx"
307 
308 # else /* unknown architecture */
309 # define ARCHITECTURE_ID ""
310 # endif
311 
312 #else
313 # define ARCHITECTURE_ID ""
314 #endif
315 
316 /* Convert integer to decimal digit literals. */
317 #define DEC(n) \
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)), \
325  ('0' + ((n) % 10))
326 
327 /* Convert integer to hex digit literals. */
328 #define HEX(n) \
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)), \
336  ('0' + ((n) & 0xF))
337 
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,
350 # endif
351 # endif
352 # endif
353  ']','\0'};
354 #endif
355 
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 "]";
362 
363 
364 
365 /*--------------------------------------------------------------------------*/
366 
367 int main(int argc, char* argv[])
368 {
369  int require = 0;
370  require += info_compiler[argc];
371  require += info_platform[argc];
372 #ifdef COMPILER_VERSION_MAJOR
373  require += info_version[argc];
374 #endif
375  (void)argv;
376  return require;
377 }
#define COMPILER_ID
#define PLATFORM_ID
int main(int argc, char *argv[])
char const * info_compiler
#define ARCHITECTURE_ID
char const * info_arch
char const * info_platform