Skip to content

Commit c65966f

Browse files
John Starkjcfr
authored andcommitted
Fix VS2010 compilation issue when PythonQt Debug build against python Release
* Copied most of the contents of vtkPython.h to dPython.h
1 parent acd9d3a commit c65966f

File tree

1 file changed

+47
-7
lines changed

1 file changed

+47
-7
lines changed

src/PythonQtPythonInclude.h

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030
*
3131
*/
3232

33+
//----------------------------------------------------------------------------------
34+
/*!
35+
// \file dPython.h - This file was copied from VTK and was originally named vtkPython.h
36+
// \author David Gobbi
37+
// \author Last changed by $Author: jcfr $
38+
// \date 2012
39+
*/
40+
//----------------------------------------------------------------------------------
41+
3342
#ifndef __PythonQtPythonInclude_h
3443
#define __PythonQtPythonInclude_h
3544

@@ -38,18 +47,49 @@
3847
#undef _POSIX_THREADS
3948
#undef _XOPEN_SOURCE
4049

50+
//
51+
// Use the real python debugging library if it is provided.
52+
// Otherwise use the "documented" trick involving checking for _DEBUG
53+
// and undefined that symbol while we include Python headers.
54+
// Update: this method does not fool Microsoft Visual C++ 8 anymore; two
55+
// of its header files (crtdefs.h and use_ansi.h) check if _DEBUG was set
56+
// or not, and set flags accordingly (_CRT_MANIFEST_RETAIL,
57+
// _CRT_MANIFEST_DEBUG, _CRT_MANIFEST_INCONSISTENT). The next time the
58+
// check is performed in the same compilation unit, and the flags are found,
59+
// and error is triggered. Let's prevent that by setting _CRT_NOFORCE_MANIFEST.
60+
//
61+
4162
// If PYTHONQT_USE_RELEASE_PYTHON_FALLBACK is enabled, try to link
4263
// release Python DLL if it is available by undefining _DEBUG while
4364
// including Python.h
4465
#if defined(PYTHONQT_USE_RELEASE_PYTHON_FALLBACK) && defined(_DEBUG)
45-
#undef _DEBUG
46-
#if defined(_MSC_VER) && _MSC_VER >= 1400
47-
#define _CRT_NOFORCE_MANIFEST 1
48-
#endif
49-
#include <Python.h>
50-
#define _DEBUG
66+
# undef _DEBUG
67+
// Include these low level headers before undefing _DEBUG. Otherwise when doing
68+
// a debug build against a release build of python the compiler will end up
69+
// including these low level headers without DEBUG enabled, causing it to try
70+
// and link release versions of this low level C api.
71+
# include <basetsd.h>
72+
# include <assert.h>
73+
# include <ctype.h>
74+
# include <errno.h>
75+
# include <io.h>
76+
# include <math.h>
77+
# include <sal.h>
78+
# include <stdarg.h>
79+
# include <stddef.h>
80+
# include <stdio.h>
81+
# include <stdlib.h>
82+
# include <string.h>
83+
# include <sys/stat.h>
84+
# include <time.h>
85+
# include <wchar.h>
86+
# if defined(_MSC_VER) && _MSC_VER >= 1400
87+
# define _CRT_NOFORCE_MANIFEST 1
88+
# endif
89+
# include <Python.h>
90+
# define _DEBUG
5191
#else
52-
#include <Python.h>
92+
# include <Python.h>
5393
#endif
5494

5595
#endif

0 commit comments

Comments
 (0)