fix(windows): Support MSVC Debug build linking against Release Python #293
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: