Skip to content

Commit

Permalink
Define _Py_NULL as nullptr on C23 and newer
Browse files Browse the repository at this point in the history
C23 standard added nullptr constant:
https://en.wikipedia.org/wiki/C23_(C_standard_revision)
  • Loading branch information
vstinner committed Aug 21, 2023
1 parent e6db23f commit 0210618
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Include/pyport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0210618

Please sign in to comment.