]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-135927: Fix MSVC Clatest C builds (GH-135935)
authorKen Jin <kenjin@python.org>
Wed, 25 Jun 2025 15:02:53 +0000 (23:02 +0800)
committerGitHub <noreply@github.com>
Wed, 25 Jun 2025 15:02:53 +0000 (23:02 +0800)
Include/pymacro.h
Include/pyport.h
Misc/NEWS.d/next/Build/2025-06-25-13-27-14.gh-issue-135927.iCNPQc.rst [new file with mode: 0644]
Modules/mathmodule.c

index bfe660e8303d0fd98dfbfde0b28ba5846a22a0de..b2886ddac5d17ed86ac8fc81e2991c2cb05240bc 100644 (file)
 #        else
 #            define _Py_ALIGNED_DEF(N, T) alignas(N) alignas(T) T
 #        endif
+#    elif defined(_MSC_VER)
+#        define _Py_ALIGNED_DEF(N, T) __declspec(align(N)) T
 #    elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 #        define _Py_ALIGNED_DEF(N, T) alignas(N) alignas(T) T
 #    elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
 #        define _Py_ALIGNED_DEF(N, T)  _Alignas(N) _Alignas(T) T
 #    elif (defined(__GNUC__) || defined(__clang__))
 #        define _Py_ALIGNED_DEF(N, T) __attribute__((aligned(N))) T
-#    elif defined(_MSC_VER)
-#        define _Py_ALIGNED_DEF(N, T) __declspec(align(N)) T
 #    else
 #        define _Py_ALIGNED_DEF(N, T) _Alignas(N) _Alignas(T) T
 #    endif
index 3eac119bf8e8d89d6f38d6ffa32221d51959ace4..73f071c41a66875e970f4bf578d5a2f0caf13eff 100644 (file)
@@ -49,7 +49,8 @@
 // Static inline functions should use _Py_NULL rather than using directly NULL
 // to prevent C++ compiler warnings. On C23 and newer and on C++11 and newer,
 // _Py_NULL is defined as nullptr.
-#if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \
+#if (defined(__GNUC__) || defined(__clang__)) && \
+    (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \
         || (defined(__cplusplus) && __cplusplus >= 201103)
 #  define _Py_NULL nullptr
 #else
diff --git a/Misc/NEWS.d/next/Build/2025-06-25-13-27-14.gh-issue-135927.iCNPQc.rst b/Misc/NEWS.d/next/Build/2025-06-25-13-27-14.gh-issue-135927.iCNPQc.rst
new file mode 100644 (file)
index 0000000..21a2c87
--- /dev/null
@@ -0,0 +1 @@
+Fix building with MSVC when passing option ``/std:clatest``.
index bbbb49115681de454368b702e0b1ac3a937b2b0d..1837de4735c1763cdf73816167656571c3630845 100644 (file)
@@ -3148,7 +3148,7 @@ static PyObject *
 math_issubnormal_impl(PyObject *module, double x)
 /*[clinic end generated code: output=4e76ac98ddcae761 input=9a20aba7107d0d95]*/
 {
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+#if !defined(_MSC_VER) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
     return PyBool_FromLong(issubnormal(x));
 #else
     return PyBool_FromLong(isfinite(x) && x && !isnormal(x));