Skip to content

Commit 68266c1

Browse files
authored
pythongh-141341: Rename COMPILER macro to _Py_COMPILER on Windows (python#141342)
1 parent 06b6228 commit 68266c1

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
On Windows, rename the ``COMPILER`` macro to ``_Py_COMPILER`` to avoid name
2+
conflicts. Patch by Victor Stinner.

PC/pyconfig.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ WIN32 is still required for the locale module.
118118
/* Microsoft C defines _MSC_VER, as does clang-cl.exe */
119119
#ifdef _MSC_VER
120120

121-
/* We want COMPILER to expand to a string containing _MSC_VER's *value*.
121+
/* We want _Py_COMPILER to expand to a string containing _MSC_VER's *value*.
122122
* This is horridly tricky, because the stringization operator only works
123123
* on macro arguments, and doesn't evaluate macros passed *as* arguments.
124124
*/
@@ -148,7 +148,7 @@ WIN32 is still required for the locale module.
148148
#define MS_WIN64
149149
#endif
150150

151-
/* set the COMPILER and support tier
151+
/* set the _Py_COMPILER and support tier
152152
*
153153
* win_amd64 MSVC (x86_64-pc-windows-msvc): 1
154154
* win32 MSVC (i686-pc-windows-msvc): 1
@@ -158,22 +158,22 @@ WIN32 is still required for the locale module.
158158
#ifdef MS_WIN64
159159
#if defined(_M_X64) || defined(_M_AMD64)
160160
#if defined(__clang__)
161-
#define COMPILER ("[Clang " __clang_version__ "] 64 bit (AMD64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
161+
#define _Py_COMPILER ("[Clang " __clang_version__ "] 64 bit (AMD64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
162162
#define PY_SUPPORT_TIER 0
163163
#elif defined(__INTEL_COMPILER)
164-
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
164+
#define _Py_COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
165165
#define PY_SUPPORT_TIER 0
166166
#else
167-
#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
167+
#define _Py_COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
168168
#define PY_SUPPORT_TIER 1
169169
#endif /* __clang__ */
170170
#define PYD_PLATFORM_TAG "win_amd64"
171171
#elif defined(_M_ARM64)
172-
#define COMPILER _Py_PASTE_VERSION("64 bit (ARM64)")
172+
#define _Py_COMPILER _Py_PASTE_VERSION("64 bit (ARM64)")
173173
#define PY_SUPPORT_TIER 3
174174
#define PYD_PLATFORM_TAG "win_arm64"
175175
#else
176-
#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
176+
#define _Py_COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
177177
#define PY_SUPPORT_TIER 0
178178
#endif
179179
#endif /* MS_WIN64 */
@@ -220,22 +220,22 @@ typedef _W64 int Py_ssize_t;
220220
#if defined(MS_WIN32) && !defined(MS_WIN64)
221221
#if defined(_M_IX86)
222222
#if defined(__clang__)
223-
#define COMPILER ("[Clang " __clang_version__ "] 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
223+
#define _Py_COMPILER ("[Clang " __clang_version__ "] 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
224224
#define PY_SUPPORT_TIER 0
225225
#elif defined(__INTEL_COMPILER)
226-
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
226+
#define _Py_COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
227227
#define PY_SUPPORT_TIER 0
228228
#else
229-
#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
229+
#define _Py_COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
230230
#define PY_SUPPORT_TIER 1
231231
#endif /* __clang__ */
232232
#define PYD_PLATFORM_TAG "win32"
233233
#elif defined(_M_ARM)
234-
#define COMPILER _Py_PASTE_VERSION("32 bit (ARM)")
234+
#define _Py_COMPILER _Py_PASTE_VERSION("32 bit (ARM)")
235235
#define PYD_PLATFORM_TAG "win_arm32"
236236
#define PY_SUPPORT_TIER 0
237237
#else
238-
#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)")
238+
#define _Py_COMPILER _Py_PASTE_VERSION("32 bit (Unknown)")
239239
#define PY_SUPPORT_TIER 0
240240
#endif
241241
#endif /* MS_WIN32 && !MS_WIN64 */
@@ -273,7 +273,7 @@ typedef int pid_t;
273273
#warning "Please use an up-to-date version of gcc! (>2.91 recommended)"
274274
#endif
275275

276-
#define COMPILER "[gcc]"
276+
#define _Py_COMPILER "[gcc]"
277277
#define PY_LONG_LONG long long
278278
#define PY_LLONG_MIN LLONG_MIN
279279
#define PY_LLONG_MAX LLONG_MAX
@@ -286,7 +286,7 @@ typedef int pid_t;
286286
/* XXX These defines are likely incomplete, but should be easy to fix.
287287
They should be complete enough to build extension modules. */
288288

289-
#define COMPILER "[lcc-win32]"
289+
#define _Py_COMPILER "[lcc-win32]"
290290
typedef int pid_t;
291291
/* __declspec() is supported here too - do nothing to get the defaults */
292292

Python/getcompiler.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include "Python.h"
55

6+
#ifdef _Py_COMPILER
7+
# define COMPILER _Py_COMPILER
8+
#endif
9+
610
#ifndef COMPILER
711

812
// Note the __clang__ conditional has to come before the __GNUC__ one because

0 commit comments

Comments
 (0)