From d35cde3120466cf990529cfbadaa825a539f242c Mon Sep 17 00:00:00 2001 From: Danny Hindson Date: Thu, 17 Mar 2022 13:41:10 +0000 Subject: [PATCH 1/2] Import crtdefs.h before undefining _DEBUG This resolves a problem generating a debug build of Mantid in VS2022 Fix based on approach taken by PyBind to similar issue --- lib/python3.8/include/wrappython.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/python3.8/include/wrappython.h b/lib/python3.8/include/wrappython.h index bfd2f93b0..b542beac9 100644 --- a/lib/python3.8/include/wrappython.h +++ b/lib/python3.8/include/wrappython.h @@ -31,6 +31,12 @@ #ifdef _DEBUG # ifndef MANTID_DEBUG_PYTHON +// Workaround for VS 2022 which doesn't like _DEBUG being messed with. Based on PyBind solution +// https://github.com/pybind/pybind11/pull/3497 +# include +# if _MSVC_STL_VERSION >= 143 +# include +# endif # undef _DEBUG // Don't let Python force the debug library just because we're debugging. # define DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H # endif From 5fae8989a249099f00265d53f47d7b6a9b87e352 Mon Sep 17 00:00:00 2001 From: Danny Hindson Date: Wed, 23 Mar 2022 13:20:32 +0000 Subject: [PATCH 2/2] Update second instance of header file with same fix To allow debug build to work in VS2022 --- build-scripts/extras/python/wrappython.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build-scripts/extras/python/wrappython.h b/build-scripts/extras/python/wrappython.h index bfd2f93b0..b542beac9 100644 --- a/build-scripts/extras/python/wrappython.h +++ b/build-scripts/extras/python/wrappython.h @@ -31,6 +31,12 @@ #ifdef _DEBUG # ifndef MANTID_DEBUG_PYTHON +// Workaround for VS 2022 which doesn't like _DEBUG being messed with. Based on PyBind solution +// https://github.com/pybind/pybind11/pull/3497 +# include +# if _MSVC_STL_VERSION >= 143 +# include +# endif # undef _DEBUG // Don't let Python force the debug library just because we're debugging. # define DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H # endif