Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 41 additions & 7 deletions src/PythonQtPythonInclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,53 @@
# include <math.h>
# endif

//
// Use the real python debugging library if it is provided.
// Otherwise use the "documented" trick involving checking for _DEBUG
// and undefined that symbol while we include Python headers.
// Update: this method does not fool Microsoft Visual C++ 8 anymore; two
// of its header files (crtdefs.h and use_ansi.h) check if _DEBUG was set
// or not, and set flags accordingly (_CRT_MANIFEST_RETAIL,
// _CRT_MANIFEST_DEBUG, _CRT_MANIFEST_INCONSISTENT). The next time the
// check is performed in the same compilation unit, and the flags are found,
// and error is triggered. Let's prevent that by setting _CRT_NOFORCE_MANIFEST.
//

// If PYTHONQT_USE_RELEASE_PYTHON_FALLBACK is enabled, try to link
// release Python DLL if it is available by undefining _DEBUG while
// including Python.h
#if defined(PYTHONQT_USE_RELEASE_PYTHON_FALLBACK) && defined(_DEBUG)
#undef _DEBUG
#if defined(_MSC_VER) && _MSC_VER >= 1400
#define _CRT_NOFORCE_MANIFEST 1
#define _STL_NOFORCE_MANIFEST 1
# define PYTHONQT_UNDEF_DEBUG
// Include these low level headers before undefing _DEBUG. Otherwise when doing
// a debug build against a release build of python the compiler will end up
// including these low level headers without DEBUG enabled, causing it to try
// and link release versions of this low level C api.
# include <basetsd.h>
# include <assert.h>
# include <ctype.h>
# include <errno.h>
# include <io.h>
# include <math.h>
# include <sal.h>
# include <stdarg.h>
# include <stddef.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <sys/stat.h>
# include <time.h>
# include <wchar.h>
# undef _DEBUG
# if defined(_MSC_VER) && _MSC_VER >= 1400
# define _CRT_NOFORCE_MANIFEST 1
# define _STL_NOFORCE_MANIFEST 1
# endif
#endif

#include <Python.h>
#define _DEBUG
#else
#include <Python.h>

#ifdef PYTHONQT_UNDEF_DEBUG
# define _DEBUG
#endif

// By including Python.h on Linux truncate could have been defined (in unistd.h)
Expand Down
Loading