spack/var/spack/repos/builtin/packages/clingo/vs2022.patch
百地 希留耶 4ff8a6a9b7
Windows: fix bootstrap and package install failure (#32942)
* Add patches for building clingo with MSVC
* Help python find clingo DLL
* If an executable is located in "C:\Program Files", Executable was
  running into issues with the extra space. This quotes the exe
  to ensure that it is treated as a single value.

Signed-off-by: Kiruya Momochi <65301509+KiruyaMomochi@users.noreply.github.com>
2022-10-26 13:45:35 -07:00

19 lines
718 B
Diff

diff --git a/libpyclingo/pyclingo.cc b/libpyclingo/pyclingo.cc
index 88b6669..58e73bd 100644
--- a/libpyclingo/pyclingo.cc
+++ b/libpyclingo/pyclingo.cc
@@ -25,6 +25,13 @@
// NOTE: the python header has a linker pragma to link with python_d.lib
// when _DEBUG is set which is not part of official python releases
#if defined(_MSC_VER) && defined(_DEBUG) && !defined(CLINGO_UNDEF__DEBUG)
+// Workaround for a VS 2022 issue.
+// NOTE: This workaround knowingly violates the Python.h include order requirement:
+// https://docs.python.org/3/c-api/intro.html#include-files
+# include <yvals.h>
+# if _MSVC_STL_VERSION >= 143
+# include <crtdefs.h>
+# endif
#undef _DEBUG
#include <Python.h>
#define _DEBUG