From dcb2544a439d446cf8fd309bec252b0616181328 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Sep 2022 05:55:54 +0100 Subject: [PATCH] Visual C++ debug builds linking to Python release builds Only use the corecrt.h workaround for #2090 when using SWIG_PYTHON_INTERPRETER_NO_DEBUG as the problem seems to only occur when undefining _DEBUG. Also extend workaround for Visual Studio 2019 version 16.10 and 16.11 as per #2174 (_MSC_VER=1929). --- Lib/python/pyruntime.swg | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg index 74669a74f..eabc829c0 100644 --- a/Lib/python/pyruntime.swg +++ b/Lib/python/pyruntime.swg @@ -4,13 +4,6 @@ # include #endif -#if defined(_MSC_VER) && _MSC_VER >= 1930 -/* Workaround what seems to be a bug in the Python headers with MSVC 2022. - * https://github.com/swig/swig/issues/2090 - */ -# include -#endif - #ifndef SWIG_NO_PY_SSIZE_T_CLEAN #define PY_SSIZE_T_CLEAN #endif @@ -24,6 +17,14 @@ #if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG) /* Use debug wrappers with the Python release dll */ + +#if defined(_MSC_VER) && _MSC_VER >= 1929 +/* Workaround what seems to be a bug in the Python headers with MSVC 2022. + * https://github.com/swig/swig/issues/2090 + */ +# include +#endif + # undef _DEBUG # include # define _DEBUG 1