summaryrefslogtreecommitdiffstats
path: root/Include/pyport.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-08-22 00:37:32 (GMT)
committerGitHub <noreply@github.com>2023-08-22 00:37:32 (GMT)
commitc965cf6dd1704a0138a4ef0a9c670e297cf66797 (patch)
tree23f087e6b189895fd183f619acede1d3cc920a34 /Include/pyport.h
parentde33b5c662ea8d35d81ed857c6a39e34ab94c510 (diff)
downloadcpython-c965cf6dd1704a0138a4ef0a9c670e297cf66797.zip
cpython-c965cf6dd1704a0138a4ef0a9c670e297cf66797.tar.gz
cpython-c965cf6dd1704a0138a4ef0a9c670e297cf66797.tar.bz2
Define _Py_NULL as nullptr on C23 and newer (#108244)
C23 standard added nullptr constant: https://en.wikipedia.org/wiki/C23_(C_standard_revision)
Diffstat (limited to 'Include/pyport.h')
-rw-r--r--Include/pyport.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/Include/pyport.h b/Include/pyport.h
index d7c6ae6..2dc2413 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -24,9 +24,10 @@
#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