Skip to content

Commit 18d42e1

Browse files
committed
Update _Py_NULL for C23
1 parent 7539c7f commit 18d42e1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pythoncapi_compat.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ extern "C" {
3030
# define _Py_CAST(type, expr) ((type)(expr))
3131
#endif
3232

33-
// On C++11 and newer, _Py_NULL is defined as nullptr on C++11,
34-
// otherwise it is defined as NULL.
35-
#ifndef _Py_NULL
36-
# if defined(__cplusplus) && __cplusplus >= 201103
37-
# define _Py_NULL nullptr
38-
# else
39-
# define _Py_NULL NULL
40-
# endif
33+
// Static inline functions should use _Py_NULL rather than using directly NULL
34+
// to prevent C++ compiler warnings. On C23 and newer and on C++11 and newer,
35+
// _Py_NULL is defined as nullptr.
36+
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \
37+
|| (defined(__cplusplus) && __cplusplus >= 201103)
38+
# define _Py_NULL nullptr
39+
#else
40+
# define _Py_NULL NULL
4141
#endif
4242

4343
// Cast argument to PyObject* type.

0 commit comments

Comments
 (0)