From 021061845e2bb60c15567c283442369dbc725ddd Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 21 Aug 2023 23:56:07 +0200 Subject: [PATCH] Define _Py_NULL as nullptr on C23 and newer C23 standard added nullptr constant: https://en.wikipedia.org/wiki/C23_(C_standard_revision) --- Include/pyport.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Include/pyport.h b/Include/pyport.h index d7c6ae64f2bf2f..2dc241389243d3 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