Guido van Rossum | f857a6b | 1996-05-23 22:50:26 +0000 | [diff] [blame] | 1 | |
Guido van Rossum | 582646a | 1996-05-28 22:30:17 +0000 | [diff] [blame] | 2 | /* Return the compiler identification, if possible. */ |
| 3 | |
| 4 | #include "Python.h" |
Guido van Rossum | f857a6b | 1996-05-23 22:50:26 +0000 | [diff] [blame] | 5 | |
| 6 | #ifndef COMPILER |
Guido van Rossum | 582646a | 1996-05-28 22:30:17 +0000 | [diff] [blame] | 7 | |
Benjamin Peterson | 7faf7e5 | 2017-10-05 21:15:14 -0700 | [diff] [blame] | 8 | // Note the __clang__ conditional has to come before the __GNUC__ one because |
| 9 | // clang pretends to be GCC. |
| 10 | #if defined(__clang__) |
| 11 | #define COMPILER "\n[Clang " __clang_version__ "]" |
| 12 | #elif defined(__GNUC__) |
Guido van Rossum | f26cda6 | 2000-09-05 04:40:39 +0000 | [diff] [blame] | 13 | #define COMPILER "\n[GCC " __VERSION__ "]" |
Benjamin Peterson | 7faf7e5 | 2017-10-05 21:15:14 -0700 | [diff] [blame] | 14 | // Generic fallbacks. |
| 15 | #elif defined(__cplusplus) |
Guido van Rossum | 667d704 | 1995-08-04 04:20:48 +0000 | [diff] [blame] | 16 | #define COMPILER "[C++]" |
| 17 | #else |
| 18 | #define COMPILER "[C]" |
| 19 | #endif |
Guido van Rossum | 582646a | 1996-05-28 22:30:17 +0000 | [diff] [blame] | 20 | |
Guido van Rossum | f857a6b | 1996-05-23 22:50:26 +0000 | [diff] [blame] | 21 | #endif /* !COMPILER */ |
Guido van Rossum | 667d704 | 1995-08-04 04:20:48 +0000 | [diff] [blame] | 22 | |
Guido van Rossum | 8fb26ed | 1997-07-19 19:48:41 +0000 | [diff] [blame] | 23 | const char * |
Thomas Wouters | f70ef4f | 2000-07-22 18:47:25 +0000 | [diff] [blame] | 24 | Py_GetCompiler(void) |
Guido van Rossum | 667d704 | 1995-08-04 04:20:48 +0000 | [diff] [blame] | 25 | { |
Benjamin Peterson | a8ed117 | 2017-10-05 00:09:01 -0700 | [diff] [blame] | 26 | return COMPILER; |
Guido van Rossum | 667d704 | 1995-08-04 04:20:48 +0000 | [diff] [blame] | 27 | } |