Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 03d3eb1

Browse files
authored
BUG: Fix order of Windows OS detection macros. (#24762)
* BUG: Fix order of Windows OS detection macros. - The order should be `__MINGW32__/__MINGW64__`, then `_WIN64`, and then `_WIN32`. 64 bit MinGW compilers define `_MINGW32__`, `__MINGW64__`, `_WIN32`, and `_WIN64`. 32 bit MinGW compilers define `__MINGW32__`, and `_WIN32`. 64 bit MSVC compilation defines `_WIN32` and `_WIN64`. 32 bit MSVC compilation defines `_WIN32`. - Fixes #24761. * Adjust the structure slightly and add comments. - This is better than just relying on the order of evaluation in the whole chain. Once Windows is detected (`_WIN32`), handle the possible known Windows environments separately. * Remove check for non-standard macros. - `WIN32`, `__WIN32__`, `WIN64`, `__WIN64__` are not standard macros defined by Window compilers. It should be enough to check for `_WIN32` and `_WIN64` alone.
1 parent 12ea98b commit 03d3eb1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

numpy/core/include/numpy/npy_os.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@
1919
#define NPY_OS_SOLARIS
2020
#elif defined(__CYGWIN__)
2121
#define NPY_OS_CYGWIN
22-
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
23-
#define NPY_OS_WIN32
24-
#elif defined(_WIN64) || defined(__WIN64__) || defined(WIN64)
25-
#define NPY_OS_WIN64
26-
#elif defined(__MINGW32__) || defined(__MINGW64__)
22+
/* We are on Windows.*/
23+
#elif defined(_WIN32)
24+
/* We are using MinGW (64-bit or 32-bit)*/
25+
#if defined(__MINGW32__) || defined(__MINGW64__)
2726
#define NPY_OS_MINGW
27+
/* Otherwise, if _WIN64 is defined, we are targeting 64-bit Windows*/
28+
#elif defined(_WIN64)
29+
#define NPY_OS_WIN64
30+
/* Otherwise assume we are targeting 32-bit Windows*/
31+
#else
32+
#define NPY_OS_WIN32
33+
#endif
2834
#elif defined(__APPLE__)
2935
#define NPY_OS_DARWIN
3036
#elif defined(__HAIKU__)

0 commit comments

Comments
 (0)