https://github.com/python/cpython/commit/a88b49c3f2184428124890741778e92c0fdb6446
commit: a88b49c3f2184428124890741778e92c0fdb6446
branch: main
author: Ken Jin <[email protected]>
committer: Fidget-Spinner <[email protected]>
date: 2025-06-25T23:02:53+08:00
summary:

gh-135927: Fix MSVC Clatest C builds (GH-135935)

files:
A Misc/NEWS.d/next/Build/2025-06-25-13-27-14.gh-issue-135927.iCNPQc.rst
M Include/pymacro.h
M Include/pyport.h
M Modules/mathmodule.c

diff --git a/Include/pymacro.h b/Include/pymacro.h
index bfe660e8303d0f..b2886ddac5d17e 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -73,14 +73,14 @@
 #        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
diff --git a/Include/pyport.h b/Include/pyport.h
index 3eac119bf8e8d8..73f071c41a6687 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -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
index 00000000000000..21a2c87d3448c1
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2025-06-25-13-27-14.gh-issue-135927.iCNPQc.rst
@@ -0,0 +1 @@
+Fix building with MSVC when passing option ``/std:clatest``.
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index bbbb49115681de..1837de4735c176 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -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));

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to