]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Define _Py_NULL as nullptr on C23 and newer (#108244)
authorVictor Stinner <vstinner@python.org>
Tue, 22 Aug 2023 00:37:32 +0000 (02:37 +0200)
committerGitHub <noreply@github.com>
Tue, 22 Aug 2023 00:37:32 +0000 (02:37 +0200)
C23 standard added nullptr constant:
https://en.wikipedia.org/wiki/C23_(C_standard_revision)

Include/pyport.h

index d7c6ae64f2bf2f05f5127fed5042c9183e130080..2dc241389243d307b55ed080ae89769a57faef19 100644 (file)
 #define _Py_CAST(type, expr) ((type)(expr))
 
 // Static inline functions should use _Py_NULL rather than using directly NULL
-// to prevent C++ compiler warnings. On C++11 and newer, _Py_NULL is defined as
-// nullptr.
-#if defined(__cplusplus) && __cplusplus >= 201103
+// 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) \
+        || (defined(__cplusplus) && __cplusplus >= 201103)
 #  define _Py_NULL nullptr
 #else
 #  define _Py_NULL NULL