Guard cxxabi.h include with __has_include for clang-cl - #6145
Open
aidaodedjl wants to merge 1 commit into
Open
Conversation
clang-cl on Windows defines __GNUG__ but does not ship <cxxabi.h>, making detail/typeid.h fail to compile. Introduce PYBIND11_HAS_CXXABI_H, defined only when <cxxabi.h> is actually available (__has_include with a fallback for compilers without it, including C++11), and use it to guard both the include and the abi::__cxa_demangle call site. Fixes pybind#6129
henryiii
approved these changes
Aug 16, 2026
Author
|
The macOS PyPy job aborted in PyPy's own |
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.
Description
clang-cl on Windows defines
__GNUG__but does not ship<cxxabi.h>, sodetail/typeid.hfails withfatal error: 'cxxabi.h' file not found.This introduces
PYBIND11_HAS_CXXABI_Has suggested by @henryiii in #6129: defined only when<cxxabi.h>is actually available, using__has_includewith a fallback for toolchains without it (pybind11 still supports C++11, where__has_includeis not guaranteed). The macro guards both the#include <cxxabi.h>and theabi::__cxa_demanglecall site inclean_type_id— guarding the include alone would leave the call undeclared.Suggested changelog entry
Fixes #6129
Verification
clean_type_idstill demangles (N4demo3FooE->demo::Foo) when the header is available.erase_allbranch without referencingcxxabi.hor__cxa_demangle.std::hash<std::type_index>,std::equal_to<std::type_index>everywhere **except when libc++ is in use** #4319).