Line |
Branch |
Exec |
Source |
1 |
|
|
#ifdef __cplusplus |
2 |
|
|
# error "A C++ compiler has been selected for C." |
3 |
|
|
#endif |
4 |
|
|
|
5 |
|
|
#if defined(__18CXX) |
6 |
|
|
# define ID_VOID_MAIN |
7 |
|
|
#endif |
8 |
|
|
#if defined(__CLASSIC_C__) |
9 |
|
|
/* cv-qualifiers did not exist in K&R C */ |
10 |
|
|
# define const |
11 |
|
|
# define volatile |
12 |
|
|
#endif |
13 |
|
|
|
14 |
|
|
|
15 |
|
|
/* Version number components: V=Version, R=Revision, P=Patch |
16 |
|
|
Version date components: YYYY=Year, MM=Month, DD=Day */ |
17 |
|
|
|
18 |
|
|
#if defined(__INTEL_COMPILER) || defined(__ICC) |
19 |
|
|
# define COMPILER_ID "Intel" |
20 |
|
|
# if defined(_MSC_VER) |
21 |
|
|
# define SIMULATE_ID "MSVC" |
22 |
|
|
# endif |
23 |
|
|
# if defined(__GNUC__) |
24 |
|
|
# define SIMULATE_ID "GNU" |
25 |
|
|
# endif |
26 |
|
|
/* __INTEL_COMPILER = VRP */ |
27 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) |
28 |
|
|
# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) |
29 |
|
|
# if defined(__INTEL_COMPILER_UPDATE) |
30 |
|
|
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) |
31 |
|
|
# else |
32 |
|
|
# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) |
33 |
|
|
# endif |
34 |
|
|
# if defined(__INTEL_COMPILER_BUILD_DATE) |
35 |
|
|
/* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ |
36 |
|
|
# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) |
37 |
|
|
# endif |
38 |
|
|
# if defined(_MSC_VER) |
39 |
|
|
/* _MSC_VER = VVRR */ |
40 |
|
|
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) |
41 |
|
|
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) |
42 |
|
|
# endif |
43 |
|
|
# if defined(__GNUC__) |
44 |
|
|
# define SIMULATE_VERSION_MAJOR DEC(__GNUC__) |
45 |
|
|
# elif defined(__GNUG__) |
46 |
|
|
# define SIMULATE_VERSION_MAJOR DEC(__GNUG__) |
47 |
|
|
# endif |
48 |
|
|
# if defined(__GNUC_MINOR__) |
49 |
|
|
# define SIMULATE_VERSION_MINOR DEC(__GNUC_MINOR__) |
50 |
|
|
# endif |
51 |
|
|
# if defined(__GNUC_PATCHLEVEL__) |
52 |
|
|
# define SIMULATE_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) |
53 |
|
|
# endif |
54 |
|
|
|
55 |
|
|
#elif defined(__PATHCC__) |
56 |
|
|
# define COMPILER_ID "PathScale" |
57 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__PATHCC__) |
58 |
|
|
# define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) |
59 |
|
|
# if defined(__PATHCC_PATCHLEVEL__) |
60 |
|
|
# define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) |
61 |
|
|
# endif |
62 |
|
|
|
63 |
|
|
#elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) |
64 |
|
|
# define COMPILER_ID "Embarcadero" |
65 |
|
|
# define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) |
66 |
|
|
# define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) |
67 |
|
|
# define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) |
68 |
|
|
|
69 |
|
|
#elif defined(__BORLANDC__) |
70 |
|
|
# define COMPILER_ID "Borland" |
71 |
|
|
/* __BORLANDC__ = 0xVRR */ |
72 |
|
|
# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) |
73 |
|
|
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) |
74 |
|
|
|
75 |
|
|
#elif defined(__WATCOMC__) && __WATCOMC__ < 1200 |
76 |
|
|
# define COMPILER_ID "Watcom" |
77 |
|
|
/* __WATCOMC__ = VVRR */ |
78 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) |
79 |
|
|
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) |
80 |
|
|
# if (__WATCOMC__ % 10) > 0 |
81 |
|
|
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) |
82 |
|
|
# endif |
83 |
|
|
|
84 |
|
|
#elif defined(__WATCOMC__) |
85 |
|
|
# define COMPILER_ID "OpenWatcom" |
86 |
|
|
/* __WATCOMC__ = VVRP + 1100 */ |
87 |
|
|
# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) |
88 |
|
|
# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) |
89 |
|
|
# if (__WATCOMC__ % 10) > 0 |
90 |
|
|
# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) |
91 |
|
|
# endif |
92 |
|
|
|
93 |
|
|
#elif defined(__SUNPRO_C) |
94 |
|
|
# define COMPILER_ID "SunPro" |
95 |
|
|
# if __SUNPRO_C >= 0x5100 |
96 |
|
|
/* __SUNPRO_C = 0xVRRP */ |
97 |
|
|
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) |
98 |
|
|
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) |
99 |
|
|
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) |
100 |
|
|
# else |
101 |
|
|
/* __SUNPRO_CC = 0xVRP */ |
102 |
|
|
# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) |
103 |
|
|
# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) |
104 |
|
|
# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) |
105 |
|
|
# endif |
106 |
|
|
|
107 |
|
|
#elif defined(__HP_cc) |
108 |
|
|
# define COMPILER_ID "HP" |
109 |
|
|
/* __HP_cc = VVRRPP */ |
110 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) |
111 |
|
|
# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) |
112 |
|
|
# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) |
113 |
|
|
|
114 |
|
|
#elif defined(__DECC) |
115 |
|
|
# define COMPILER_ID "Compaq" |
116 |
|
|
/* __DECC_VER = VVRRTPPPP */ |
117 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) |
118 |
|
|
# define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) |
119 |
|
|
# define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) |
120 |
|
|
|
121 |
|
|
#elif defined(__IBMC__) && defined(__COMPILER_VER__) |
122 |
|
|
# define COMPILER_ID "zOS" |
123 |
|
|
/* __IBMC__ = VRP */ |
124 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) |
125 |
|
|
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) |
126 |
|
|
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) |
127 |
|
|
|
128 |
|
|
#elif defined(__ibmxl__) && defined(__clang__) |
129 |
|
|
# define COMPILER_ID "XLClang" |
130 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__ibmxl_version__) |
131 |
|
|
# define COMPILER_VERSION_MINOR DEC(__ibmxl_release__) |
132 |
|
|
# define COMPILER_VERSION_PATCH DEC(__ibmxl_modification__) |
133 |
|
|
# define COMPILER_VERSION_TWEAK DEC(__ibmxl_ptf_fix_level__) |
134 |
|
|
|
135 |
|
|
|
136 |
|
|
#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800 |
137 |
|
|
# define COMPILER_ID "XL" |
138 |
|
|
/* __IBMC__ = VRP */ |
139 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) |
140 |
|
|
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) |
141 |
|
|
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) |
142 |
|
|
|
143 |
|
|
#elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800 |
144 |
|
|
# define COMPILER_ID "VisualAge" |
145 |
|
|
/* __IBMC__ = VRP */ |
146 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) |
147 |
|
|
# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) |
148 |
|
|
# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) |
149 |
|
|
|
150 |
|
|
#elif defined(__PGI) |
151 |
|
|
# define COMPILER_ID "PGI" |
152 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__PGIC__) |
153 |
|
|
# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) |
154 |
|
|
# if defined(__PGIC_PATCHLEVEL__) |
155 |
|
|
# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) |
156 |
|
|
# endif |
157 |
|
|
|
158 |
|
|
#elif defined(_CRAYC) |
159 |
|
|
# define COMPILER_ID "Cray" |
160 |
|
|
# define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) |
161 |
|
|
# define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) |
162 |
|
|
|
163 |
|
|
#elif defined(__TI_COMPILER_VERSION__) |
164 |
|
|
# define COMPILER_ID "TI" |
165 |
|
|
/* __TI_COMPILER_VERSION__ = VVVRRRPPP */ |
166 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) |
167 |
|
|
# define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) |
168 |
|
|
# define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) |
169 |
|
|
|
170 |
|
|
#elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version) |
171 |
|
|
# define COMPILER_ID "Fujitsu" |
172 |
|
|
|
173 |
|
|
#elif defined(__ghs__) |
174 |
|
|
# define COMPILER_ID "GHS" |
175 |
|
|
/* __GHS_VERSION_NUMBER = VVVVRP */ |
176 |
|
|
# ifdef __GHS_VERSION_NUMBER |
177 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__GHS_VERSION_NUMBER / 100) |
178 |
|
|
# define COMPILER_VERSION_MINOR DEC(__GHS_VERSION_NUMBER / 10 % 10) |
179 |
|
|
# define COMPILER_VERSION_PATCH DEC(__GHS_VERSION_NUMBER % 10) |
180 |
|
|
# endif |
181 |
|
|
|
182 |
|
|
#elif defined(__TINYC__) |
183 |
|
|
# define COMPILER_ID "TinyCC" |
184 |
|
|
|
185 |
|
|
#elif defined(__BCC__) |
186 |
|
|
# define COMPILER_ID "Bruce" |
187 |
|
|
|
188 |
|
|
#elif defined(__SCO_VERSION__) |
189 |
|
|
# define COMPILER_ID "SCO" |
190 |
|
|
|
191 |
|
|
#elif defined(__ARMCC_VERSION) && !defined(__clang__) |
192 |
|
|
# define COMPILER_ID "ARMCC" |
193 |
|
|
#if __ARMCC_VERSION >= 1000000 |
194 |
|
|
/* __ARMCC_VERSION = VRRPPPP */ |
195 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) |
196 |
|
|
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) |
197 |
|
|
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) |
198 |
|
|
#else |
199 |
|
|
/* __ARMCC_VERSION = VRPPPP */ |
200 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) |
201 |
|
|
# define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) |
202 |
|
|
# define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) |
203 |
|
|
#endif |
204 |
|
|
|
205 |
|
|
|
206 |
|
|
#elif defined(__clang__) && defined(__apple_build_version__) |
207 |
|
|
# define COMPILER_ID "AppleClang" |
208 |
|
|
# if defined(_MSC_VER) |
209 |
|
|
# define SIMULATE_ID "MSVC" |
210 |
|
|
# endif |
211 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__clang_major__) |
212 |
|
|
# define COMPILER_VERSION_MINOR DEC(__clang_minor__) |
213 |
|
|
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) |
214 |
|
|
# if defined(_MSC_VER) |
215 |
|
|
/* _MSC_VER = VVRR */ |
216 |
|
|
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) |
217 |
|
|
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) |
218 |
|
|
# endif |
219 |
|
|
# define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) |
220 |
|
|
|
221 |
|
|
#elif defined(__clang__) && defined(__ARMCOMPILER_VERSION) |
222 |
|
|
# define COMPILER_ID "ARMClang" |
223 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__ARMCOMPILER_VERSION/1000000) |
224 |
|
|
# define COMPILER_VERSION_MINOR DEC(__ARMCOMPILER_VERSION/10000 % 100) |
225 |
|
|
# define COMPILER_VERSION_PATCH DEC(__ARMCOMPILER_VERSION % 10000) |
226 |
|
|
# define COMPILER_VERSION_INTERNAL DEC(__ARMCOMPILER_VERSION) |
227 |
|
|
|
228 |
|
|
#elif defined(__clang__) |
229 |
|
|
# define COMPILER_ID "Clang" |
230 |
|
|
# if defined(_MSC_VER) |
231 |
|
|
# define SIMULATE_ID "MSVC" |
232 |
|
|
# endif |
233 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__clang_major__) |
234 |
|
|
# define COMPILER_VERSION_MINOR DEC(__clang_minor__) |
235 |
|
|
# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) |
236 |
|
|
# if defined(_MSC_VER) |
237 |
|
|
/* _MSC_VER = VVRR */ |
238 |
|
|
# define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) |
239 |
|
|
# define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) |
240 |
|
|
# endif |
241 |
|
|
|
242 |
|
|
#elif defined(__GNUC__) |
243 |
|
|
# define COMPILER_ID "GNU" |
244 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__GNUC__) |
245 |
|
|
# if defined(__GNUC_MINOR__) |
246 |
|
|
# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) |
247 |
|
|
# endif |
248 |
|
|
# if defined(__GNUC_PATCHLEVEL__) |
249 |
|
|
# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) |
250 |
|
|
# endif |
251 |
|
|
|
252 |
|
|
#elif defined(_MSC_VER) |
253 |
|
|
# define COMPILER_ID "MSVC" |
254 |
|
|
/* _MSC_VER = VVRR */ |
255 |
|
|
# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) |
256 |
|
|
# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) |
257 |
|
|
# if defined(_MSC_FULL_VER) |
258 |
|
|
# if _MSC_VER >= 1400 |
259 |
|
|
/* _MSC_FULL_VER = VVRRPPPPP */ |
260 |
|
|
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) |
261 |
|
|
# else |
262 |
|
|
/* _MSC_FULL_VER = VVRRPPPP */ |
263 |
|
|
# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) |
264 |
|
|
# endif |
265 |
|
|
# endif |
266 |
|
|
# if defined(_MSC_BUILD) |
267 |
|
|
# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) |
268 |
|
|
# endif |
269 |
|
|
|
270 |
|
|
#elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) |
271 |
|
|
# define COMPILER_ID "ADSP" |
272 |
|
|
#if defined(__VISUALDSPVERSION__) |
273 |
|
|
/* __VISUALDSPVERSION__ = 0xVVRRPP00 */ |
274 |
|
|
# define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) |
275 |
|
|
# define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) |
276 |
|
|
# define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) |
277 |
|
|
#endif |
278 |
|
|
|
279 |
|
|
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) |
280 |
|
|
# define COMPILER_ID "IAR" |
281 |
|
|
# if defined(__VER__) && defined(__ICCARM__) |
282 |
|
|
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 1000000) |
283 |
|
|
# define COMPILER_VERSION_MINOR DEC(((__VER__) / 1000) % 1000) |
284 |
|
|
# define COMPILER_VERSION_PATCH DEC((__VER__) % 1000) |
285 |
|
|
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) |
286 |
|
|
# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__) || defined(__ICC8051__)) |
287 |
|
|
# define COMPILER_VERSION_MAJOR DEC((__VER__) / 100) |
288 |
|
|
# define COMPILER_VERSION_MINOR DEC((__VER__) - (((__VER__) / 100)*100)) |
289 |
|
|
# define COMPILER_VERSION_PATCH DEC(__SUBVERSION__) |
290 |
|
|
# define COMPILER_VERSION_INTERNAL DEC(__IAR_SYSTEMS_ICC__) |
291 |
|
|
# endif |
292 |
|
|
|
293 |
|
|
#elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC) |
294 |
|
|
# define COMPILER_ID "SDCC" |
295 |
|
|
# if defined(__SDCC_VERSION_MAJOR) |
296 |
|
|
# define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR) |
297 |
|
|
# define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR) |
298 |
|
|
# define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH) |
299 |
|
|
# else |
300 |
|
|
/* SDCC = VRP */ |
301 |
|
|
# define COMPILER_VERSION_MAJOR DEC(SDCC/100) |
302 |
|
|
# define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) |
303 |
|
|
# define COMPILER_VERSION_PATCH DEC(SDCC % 10) |
304 |
|
|
# endif |
305 |
|
|
|
306 |
|
|
|
307 |
|
|
/* These compilers are either not known or too old to define an |
308 |
|
|
identification macro. Try to identify the platform and guess that |
309 |
|
|
it is the native compiler. */ |
310 |
|
|
#elif defined(__hpux) || defined(__hpua) |
311 |
|
|
# define COMPILER_ID "HP" |
312 |
|
|
|
313 |
|
|
#else /* unknown compiler */ |
314 |
|
|
# define COMPILER_ID "" |
315 |
|
|
#endif |
316 |
|
|
|
317 |
|
|
/* Construct the string literal in pieces to prevent the source from |
318 |
|
|
getting matched. Store it in a pointer rather than an array |
319 |
|
|
because some compilers will just produce instructions to fill the |
320 |
|
|
array rather than assigning a pointer to a static array. */ |
321 |
|
|
char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; |
322 |
|
|
#ifdef SIMULATE_ID |
323 |
|
|
char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; |
324 |
|
|
#endif |
325 |
|
|
|
326 |
|
|
#ifdef __QNXNTO__ |
327 |
|
|
char const* qnxnto = "INFO" ":" "qnxnto[]"; |
328 |
|
|
#endif |
329 |
|
|
|
330 |
|
|
#if defined(__CRAYXE) || defined(__CRAYXC) |
331 |
|
|
char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; |
332 |
|
|
#endif |
333 |
|
|
|
334 |
|
|
#define STRINGIFY_HELPER(X) #X |
335 |
|
|
#define STRINGIFY(X) STRINGIFY_HELPER(X) |
336 |
|
|
|
337 |
|
|
/* Identify known platforms by name. */ |
338 |
|
|
#if defined(__linux) || defined(__linux__) || defined(linux) |
339 |
|
|
# define PLATFORM_ID "Linux" |
340 |
|
|
|
341 |
|
|
#elif defined(__CYGWIN__) |
342 |
|
|
# define PLATFORM_ID "Cygwin" |
343 |
|
|
|
344 |
|
|
#elif defined(__MINGW32__) |
345 |
|
|
# define PLATFORM_ID "MinGW" |
346 |
|
|
|
347 |
|
|
#elif defined(__APPLE__) |
348 |
|
|
# define PLATFORM_ID "Darwin" |
349 |
|
|
|
350 |
|
|
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) |
351 |
|
|
# define PLATFORM_ID "Windows" |
352 |
|
|
|
353 |
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD) |
354 |
|
|
# define PLATFORM_ID "FreeBSD" |
355 |
|
|
|
356 |
|
|
#elif defined(__NetBSD__) || defined(__NetBSD) |
357 |
|
|
# define PLATFORM_ID "NetBSD" |
358 |
|
|
|
359 |
|
|
#elif defined(__OpenBSD__) || defined(__OPENBSD) |
360 |
|
|
# define PLATFORM_ID "OpenBSD" |
361 |
|
|
|
362 |
|
|
#elif defined(__sun) || defined(sun) |
363 |
|
|
# define PLATFORM_ID "SunOS" |
364 |
|
|
|
365 |
|
|
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) |
366 |
|
|
# define PLATFORM_ID "AIX" |
367 |
|
|
|
368 |
|
|
#elif defined(__hpux) || defined(__hpux__) |
369 |
|
|
# define PLATFORM_ID "HP-UX" |
370 |
|
|
|
371 |
|
|
#elif defined(__HAIKU__) |
372 |
|
|
# define PLATFORM_ID "Haiku" |
373 |
|
|
|
374 |
|
|
#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) |
375 |
|
|
# define PLATFORM_ID "BeOS" |
376 |
|
|
|
377 |
|
|
#elif defined(__QNX__) || defined(__QNXNTO__) |
378 |
|
|
# define PLATFORM_ID "QNX" |
379 |
|
|
|
380 |
|
|
#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) |
381 |
|
|
# define PLATFORM_ID "Tru64" |
382 |
|
|
|
383 |
|
|
#elif defined(__riscos) || defined(__riscos__) |
384 |
|
|
# define PLATFORM_ID "RISCos" |
385 |
|
|
|
386 |
|
|
#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) |
387 |
|
|
# define PLATFORM_ID "SINIX" |
388 |
|
|
|
389 |
|
|
#elif defined(__UNIX_SV__) |
390 |
|
|
# define PLATFORM_ID "UNIX_SV" |
391 |
|
|
|
392 |
|
|
#elif defined(__bsdos__) |
393 |
|
|
# define PLATFORM_ID "BSDOS" |
394 |
|
|
|
395 |
|
|
#elif defined(_MPRAS) || defined(MPRAS) |
396 |
|
|
# define PLATFORM_ID "MP-RAS" |
397 |
|
|
|
398 |
|
|
#elif defined(__osf) || defined(__osf__) |
399 |
|
|
# define PLATFORM_ID "OSF1" |
400 |
|
|
|
401 |
|
|
#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) |
402 |
|
|
# define PLATFORM_ID "SCO_SV" |
403 |
|
|
|
404 |
|
|
#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) |
405 |
|
|
# define PLATFORM_ID "ULTRIX" |
406 |
|
|
|
407 |
|
|
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) |
408 |
|
|
# define PLATFORM_ID "Xenix" |
409 |
|
|
|
410 |
|
|
#elif defined(__WATCOMC__) |
411 |
|
|
# if defined(__LINUX__) |
412 |
|
|
# define PLATFORM_ID "Linux" |
413 |
|
|
|
414 |
|
|
# elif defined(__DOS__) |
415 |
|
|
# define PLATFORM_ID "DOS" |
416 |
|
|
|
417 |
|
|
# elif defined(__OS2__) |
418 |
|
|
# define PLATFORM_ID "OS2" |
419 |
|
|
|
420 |
|
|
# elif defined(__WINDOWS__) |
421 |
|
|
# define PLATFORM_ID "Windows3x" |
422 |
|
|
|
423 |
|
|
# else /* unknown platform */ |
424 |
|
|
# define PLATFORM_ID |
425 |
|
|
# endif |
426 |
|
|
|
427 |
|
|
#elif defined(__INTEGRITY) |
428 |
|
|
# if defined(INT_178B) |
429 |
|
|
# define PLATFORM_ID "Integrity178" |
430 |
|
|
|
431 |
|
|
# else /* regular Integrity */ |
432 |
|
|
# define PLATFORM_ID "Integrity" |
433 |
|
|
# endif |
434 |
|
|
|
435 |
|
|
#else /* unknown platform */ |
436 |
|
|
# define PLATFORM_ID |
437 |
|
|
|
438 |
|
|
#endif |
439 |
|
|
|
440 |
|
|
/* For windows compilers MSVC and Intel we can determine |
441 |
|
|
the architecture of the compiler being used. This is because |
442 |
|
|
the compilers do not have flags that can change the architecture, |
443 |
|
|
but rather depend on which compiler is being used |
444 |
|
|
*/ |
445 |
|
|
#if defined(_WIN32) && defined(_MSC_VER) |
446 |
|
|
# if defined(_M_IA64) |
447 |
|
|
# define ARCHITECTURE_ID "IA64" |
448 |
|
|
|
449 |
|
|
# elif defined(_M_X64) || defined(_M_AMD64) |
450 |
|
|
# define ARCHITECTURE_ID "x64" |
451 |
|
|
|
452 |
|
|
# elif defined(_M_IX86) |
453 |
|
|
# define ARCHITECTURE_ID "X86" |
454 |
|
|
|
455 |
|
|
# elif defined(_M_ARM64) |
456 |
|
|
# define ARCHITECTURE_ID "ARM64" |
457 |
|
|
|
458 |
|
|
# elif defined(_M_ARM) |
459 |
|
|
# if _M_ARM == 4 |
460 |
|
|
# define ARCHITECTURE_ID "ARMV4I" |
461 |
|
|
# elif _M_ARM == 5 |
462 |
|
|
# define ARCHITECTURE_ID "ARMV5I" |
463 |
|
|
# else |
464 |
|
|
# define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) |
465 |
|
|
# endif |
466 |
|
|
|
467 |
|
|
# elif defined(_M_MIPS) |
468 |
|
|
# define ARCHITECTURE_ID "MIPS" |
469 |
|
|
|
470 |
|
|
# elif defined(_M_SH) |
471 |
|
|
# define ARCHITECTURE_ID "SHx" |
472 |
|
|
|
473 |
|
|
# else /* unknown architecture */ |
474 |
|
|
# define ARCHITECTURE_ID "" |
475 |
|
|
# endif |
476 |
|
|
|
477 |
|
|
#elif defined(__WATCOMC__) |
478 |
|
|
# if defined(_M_I86) |
479 |
|
|
# define ARCHITECTURE_ID "I86" |
480 |
|
|
|
481 |
|
|
# elif defined(_M_IX86) |
482 |
|
|
# define ARCHITECTURE_ID "X86" |
483 |
|
|
|
484 |
|
|
# else /* unknown architecture */ |
485 |
|
|
# define ARCHITECTURE_ID "" |
486 |
|
|
# endif |
487 |
|
|
|
488 |
|
|
#elif defined(__IAR_SYSTEMS_ICC__) || defined(__IAR_SYSTEMS_ICC) |
489 |
|
|
# if defined(__ICCARM__) |
490 |
|
|
# define ARCHITECTURE_ID "ARM" |
491 |
|
|
|
492 |
|
|
# elif defined(__ICCRX__) |
493 |
|
|
# define ARCHITECTURE_ID "RX" |
494 |
|
|
|
495 |
|
|
# elif defined(__ICCRH850__) |
496 |
|
|
# define ARCHITECTURE_ID "RH850" |
497 |
|
|
|
498 |
|
|
# elif defined(__ICCRL78__) |
499 |
|
|
# define ARCHITECTURE_ID "RL78" |
500 |
|
|
|
501 |
|
|
# elif defined(__ICCRISCV__) |
502 |
|
|
# define ARCHITECTURE_ID "RISCV" |
503 |
|
|
|
504 |
|
|
# elif defined(__ICCAVR__) |
505 |
|
|
# define ARCHITECTURE_ID "AVR" |
506 |
|
|
|
507 |
|
|
# elif defined(__ICC430__) |
508 |
|
|
# define ARCHITECTURE_ID "MSP430" |
509 |
|
|
|
510 |
|
|
# elif defined(__ICCV850__) |
511 |
|
|
# define ARCHITECTURE_ID "V850" |
512 |
|
|
|
513 |
|
|
# elif defined(__ICC8051__) |
514 |
|
|
# define ARCHITECTURE_ID "8051" |
515 |
|
|
|
516 |
|
|
# else /* unknown architecture */ |
517 |
|
|
# define ARCHITECTURE_ID "" |
518 |
|
|
# endif |
519 |
|
|
|
520 |
|
|
#elif defined(__ghs__) |
521 |
|
|
# if defined(__PPC64__) |
522 |
|
|
# define ARCHITECTURE_ID "PPC64" |
523 |
|
|
|
524 |
|
|
# elif defined(__ppc__) |
525 |
|
|
# define ARCHITECTURE_ID "PPC" |
526 |
|
|
|
527 |
|
|
# elif defined(__ARM__) |
528 |
|
|
# define ARCHITECTURE_ID "ARM" |
529 |
|
|
|
530 |
|
|
# elif defined(__x86_64__) |
531 |
|
|
# define ARCHITECTURE_ID "x64" |
532 |
|
|
|
533 |
|
|
# elif defined(__i386__) |
534 |
|
|
# define ARCHITECTURE_ID "X86" |
535 |
|
|
|
536 |
|
|
# else /* unknown architecture */ |
537 |
|
|
# define ARCHITECTURE_ID "" |
538 |
|
|
# endif |
539 |
|
|
#else |
540 |
|
|
# define ARCHITECTURE_ID |
541 |
|
|
#endif |
542 |
|
|
|
543 |
|
|
/* Convert integer to decimal digit literals. */ |
544 |
|
|
#define DEC(n) \ |
545 |
|
|
('0' + (((n) / 10000000)%10)), \ |
546 |
|
|
('0' + (((n) / 1000000)%10)), \ |
547 |
|
|
('0' + (((n) / 100000)%10)), \ |
548 |
|
|
('0' + (((n) / 10000)%10)), \ |
549 |
|
|
('0' + (((n) / 1000)%10)), \ |
550 |
|
|
('0' + (((n) / 100)%10)), \ |
551 |
|
|
('0' + (((n) / 10)%10)), \ |
552 |
|
|
('0' + ((n) % 10)) |
553 |
|
|
|
554 |
|
|
/* Convert integer to hex digit literals. */ |
555 |
|
|
#define HEX(n) \ |
556 |
|
|
('0' + ((n)>>28 & 0xF)), \ |
557 |
|
|
('0' + ((n)>>24 & 0xF)), \ |
558 |
|
|
('0' + ((n)>>20 & 0xF)), \ |
559 |
|
|
('0' + ((n)>>16 & 0xF)), \ |
560 |
|
|
('0' + ((n)>>12 & 0xF)), \ |
561 |
|
|
('0' + ((n)>>8 & 0xF)), \ |
562 |
|
|
('0' + ((n)>>4 & 0xF)), \ |
563 |
|
|
('0' + ((n) & 0xF)) |
564 |
|
|
|
565 |
|
|
/* Construct a string literal encoding the version number components. */ |
566 |
|
|
#ifdef COMPILER_VERSION_MAJOR |
567 |
|
|
char const info_version[] = { |
568 |
|
|
'I', 'N', 'F', 'O', ':', |
569 |
|
|
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', |
570 |
|
|
COMPILER_VERSION_MAJOR, |
571 |
|
|
# ifdef COMPILER_VERSION_MINOR |
572 |
|
|
'.', COMPILER_VERSION_MINOR, |
573 |
|
|
# ifdef COMPILER_VERSION_PATCH |
574 |
|
|
'.', COMPILER_VERSION_PATCH, |
575 |
|
|
# ifdef COMPILER_VERSION_TWEAK |
576 |
|
|
'.', COMPILER_VERSION_TWEAK, |
577 |
|
|
# endif |
578 |
|
|
# endif |
579 |
|
|
# endif |
580 |
|
|
']','\0'}; |
581 |
|
|
#endif |
582 |
|
|
|
583 |
|
|
/* Construct a string literal encoding the internal version number. */ |
584 |
|
|
#ifdef COMPILER_VERSION_INTERNAL |
585 |
|
|
char const info_version_internal[] = { |
586 |
|
|
'I', 'N', 'F', 'O', ':', |
587 |
|
|
'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', |
588 |
|
|
'i','n','t','e','r','n','a','l','[', |
589 |
|
|
COMPILER_VERSION_INTERNAL,']','\0'}; |
590 |
|
|
#endif |
591 |
|
|
|
592 |
|
|
/* Construct a string literal encoding the version number components. */ |
593 |
|
|
#ifdef SIMULATE_VERSION_MAJOR |
594 |
|
|
char const info_simulate_version[] = { |
595 |
|
|
'I', 'N', 'F', 'O', ':', |
596 |
|
|
's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', |
597 |
|
|
SIMULATE_VERSION_MAJOR, |
598 |
|
|
# ifdef SIMULATE_VERSION_MINOR |
599 |
|
|
'.', SIMULATE_VERSION_MINOR, |
600 |
|
|
# ifdef SIMULATE_VERSION_PATCH |
601 |
|
|
'.', SIMULATE_VERSION_PATCH, |
602 |
|
|
# ifdef SIMULATE_VERSION_TWEAK |
603 |
|
|
'.', SIMULATE_VERSION_TWEAK, |
604 |
|
|
# endif |
605 |
|
|
# endif |
606 |
|
|
# endif |
607 |
|
|
']','\0'}; |
608 |
|
|
#endif |
609 |
|
|
|
610 |
|
|
/* Construct the string literal in pieces to prevent the source from |
611 |
|
|
getting matched. Store it in a pointer rather than an array |
612 |
|
|
because some compilers will just produce instructions to fill the |
613 |
|
|
array rather than assigning a pointer to a static array. */ |
614 |
|
|
char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; |
615 |
|
|
char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; |
616 |
|
|
|
617 |
|
|
|
618 |
|
|
|
619 |
|
|
|
620 |
|
|
#if !defined(__STDC__) |
621 |
|
|
# if (defined(_MSC_VER) && !defined(__clang__)) \ |
622 |
|
|
|| (defined(__ibmxl__) || defined(__IBMC__)) |
623 |
|
|
# define C_DIALECT "90" |
624 |
|
|
# else |
625 |
|
|
# define C_DIALECT |
626 |
|
|
# endif |
627 |
|
|
#elif __STDC_VERSION__ >= 201000L |
628 |
|
|
# define C_DIALECT "11" |
629 |
|
|
#elif __STDC_VERSION__ >= 199901L |
630 |
|
|
# define C_DIALECT "99" |
631 |
|
|
#else |
632 |
|
|
# define C_DIALECT "90" |
633 |
|
|
#endif |
634 |
|
|
const char* info_language_dialect_default = |
635 |
|
|
"INFO" ":" "dialect_default[" C_DIALECT "]"; |
636 |
|
|
|
637 |
|
|
/*--------------------------------------------------------------------------*/ |
638 |
|
|
|
639 |
|
|
#ifdef ID_VOID_MAIN |
640 |
|
|
void main() {} |
641 |
|
|
#else |
642 |
|
|
# if defined(__CLASSIC_C__) |
643 |
|
|
int main(argc, argv) int argc; char *argv[]; |
644 |
|
|
# else |
645 |
|
✗ |
int main(int argc, char* argv[]) |
646 |
|
|
# endif |
647 |
|
|
{ |
648 |
|
✗ |
int require = 0; |
649 |
|
✗ |
require += info_compiler[argc]; |
650 |
|
✗ |
require += info_platform[argc]; |
651 |
|
✗ |
require += info_arch[argc]; |
652 |
|
|
#ifdef COMPILER_VERSION_MAJOR |
653 |
|
✗ |
require += info_version[argc]; |
654 |
|
|
#endif |
655 |
|
|
#ifdef COMPILER_VERSION_INTERNAL |
656 |
|
|
require += info_version_internal[argc]; |
657 |
|
|
#endif |
658 |
|
|
#ifdef SIMULATE_ID |
659 |
|
|
require += info_simulate[argc]; |
660 |
|
|
#endif |
661 |
|
|
#ifdef SIMULATE_VERSION_MAJOR |
662 |
|
|
require += info_simulate_version[argc]; |
663 |
|
|
#endif |
664 |
|
|
#if defined(__CRAYXE) || defined(__CRAYXC) |
665 |
|
|
require += info_cray[argc]; |
666 |
|
|
#endif |
667 |
|
✗ |
require += info_language_dialect_default[argc]; |
668 |
|
|
(void)argv; |
669 |
|
✗ |
return require; |
670 |
|
|
} |
671 |
|
|
#endif |
672 |
|
|
|