Skip to content

Commit c965cf6

Browse files
authored
Define _Py_NULL as nullptr on C23 and newer (#108244)
C23 standard added nullptr constant: https://en.wikipedia.org/wiki/C23_(C_standard_revision)
1 parent de33b5c commit c965cf6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Include/pyport.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
#define _Py_CAST(type, expr) ((type)(expr))
2525

2626
// Static inline functions should use _Py_NULL rather than using directly NULL
27-
// to prevent C++ compiler warnings. On C++11 and newer, _Py_NULL is defined as
28-
// nullptr.
29-
#if defined(__cplusplus) && __cplusplus >= 201103
27+
// to prevent C++ compiler warnings. On C23 and newer and on C++11 and newer,
28+
// _Py_NULL is defined as nullptr.
29+
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \
30+
|| (defined(__cplusplus) && __cplusplus >= 201103)
3031
# define _Py_NULL nullptr
3132
#else
3233
# define _Py_NULL NULL

0 commit comments

Comments
 (0)