From ad366d0422225146f24881abeeef7f972f81edcd Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 18 Feb 2025 11:00:03 +0100 Subject: [PATCH] Don't redefine _Py_NULL macro if already defined Original mypy fix by Michael R. Crusoe. --- pythoncapi_compat.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pythoncapi_compat.h b/pythoncapi_compat.h index 4d28846..836df7e 100644 --- a/pythoncapi_compat.h +++ b/pythoncapi_compat.h @@ -37,11 +37,13 @@ extern "C" { // Static inline functions should use _Py_NULL rather than using directly NULL // 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 +#ifndef _Py_NULL +# if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \ + || (defined(__cplusplus) && __cplusplus >= 201103) +# define _Py_NULL nullptr +# else +# define _Py_NULL NULL +# endif #endif // Cast argument to PyObject* type.