summaryrefslogtreecommitdiffstats
path: root/Include/pyport.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-03 19:38:37 (GMT)
committerGitHub <noreply@github.com>2022-05-03 19:38:37 (GMT)
commit551d02b3e697098236bb3a6e0a855b2ad8dc0424 (patch)
treeffa7db7f5129f7167df4c40bf4bbed2f5481c28b /Include/pyport.h
parent456cd513e360ccd17e51ae3711ec48976b1be0c0 (diff)
downloadcpython-551d02b3e697098236bb3a6e0a855b2ad8dc0424.zip
cpython-551d02b3e697098236bb3a6e0a855b2ad8dc0424.tar.gz
cpython-551d02b3e697098236bb3a6e0a855b2ad8dc0424.tar.bz2
gh-91321: Add _Py_NULL macro (#92253)
Fix C++ compiler warnings: "zero as null pointer constant" (clang -Wzero-as-null-pointer-constant). * Add the _Py_NULL macro used by static inline functions to use nullptr in C++. * Replace NULL with nullptr in _testcppext.cpp.
Diffstat (limited to 'Include/pyport.h')
-rw-r--r--Include/pyport.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Include/pyport.h b/Include/pyport.h
index f6270be..614a278 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -33,6 +33,14 @@
# define _Py_CAST(type, expr) ((type)(expr))
#endif
+// Static inline functions should use _Py_NULL rather than using directly NULL
+// to prevent C++ compiler warnings. In C++, _Py_NULL uses nullptr.
+#ifdef __cplusplus
+# define _Py_NULL nullptr
+#else
+# define _Py_NULL NULL
+#endif
+
/* Defines to build Python and its standard library:
*