fix(windows): Support MSVC Debug build linking against Release Python#293
Merged
mrbean-bremen merged 2 commits intoMeVisLab:masterfrom Sep 1, 2025
Conversation
…elease Copied most of the contents of `vtkPython.h` (cherry picked from commit commontk/PythonQt@8a50eaa) Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
By ensuring that "undef" of _DEBUG macro is not done before system includes, it fixes the issue. Based on a similar fix in VTK. See: Kitware/VTK@81d4a72 See: commontk/PythonQt#9 Thanks to @Neosettler for reporting and testing. Reported-by: Neosettler (cherry picked from commit commontk/PythonQt@77d8177)
Contributor
Author
|
Suggested commit message if squashing: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes Windows/MSVC build and link issues when PythonQt is built in Debug while linking against a Release Python (e.g., only
pythonXY.dll/pythonXY.libare available).Summary:
Adopt the strategy used in VTK to temporarily undefine
_DEBUGonly for thePython.hinclusion, while:_DEBUGto avoid pulling in release-mode CRT variants inadvertently._CRT_NOFORCE_MANIFESTand_STL_NOFORCE_MANIFESTon MSVC ≥ 1400 to prevent inconsistent CRT manifest flags._DEBUGafterward to keep the rest of the TU in the correct debug configuration.Wrap the behavior with a small guard macro:
PYTHONQT_UNDEF_DEBUGso we can safely re-define_DEBUGonly when we actually changed it.All changes are conditioned on
PYTHONQT_USE_RELEASE_PYTHON_FALLBACK && _DEBUG.Motivation:
Without these adjustments, MSVC may:
_CRT_MANIFEST_DEBUG,_CRT_MANIFEST_RETAIL,_CRT_MANIFEST_INCONSISTENT) across the same Translation Unit._invalid_parameter_noinfo_noreturndue to mismatched debug/release CRT resolution caused by including system headers with the wrong_DEBUGstate.References: