Skip to content

Commit 632d1aa

Browse files
authored
Don't redefine _Py_NULL macro if already defined (#138)
Original mypy fix by Michael R. Crusoe.
1 parent c84545f commit 632d1aa

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pythoncapi_compat.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ extern "C" {
3737
// Static inline functions should use _Py_NULL rather than using directly NULL
3838
// to prevent C++ compiler warnings. On C23 and newer and on C++11 and newer,
3939
// _Py_NULL is defined as nullptr.
40-
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \
41-
|| (defined(__cplusplus) && __cplusplus >= 201103)
42-
# define _Py_NULL nullptr
43-
#else
44-
# define _Py_NULL NULL
40+
#ifndef _Py_NULL
41+
# if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \
42+
|| (defined(__cplusplus) && __cplusplus >= 201103)
43+
# define _Py_NULL nullptr
44+
# else
45+
# define _Py_NULL NULL
46+
# endif
4547
#endif
4648

4749
// Cast argument to PyObject* type.

0 commit comments

Comments
 (0)