Fix Clang Boost wchar_t redefinition#539
Open
ruiji-shi wants to merge 1 commit into
Open
Conversation
When clang targets MSVC compatibility (clang-cl, so _MSC_VER is defined) and
is built with /Zc:wchar_t- , wchar_t is an alias for unsigned short rather than
a distinct intrinsic type, and _NATIVE_WCHAR_T_DEFINED is not defined.
In that configuration Boost emits a separate is_integral<wchar_t> (and related
is_signed/is_unsigned/integer_traits/... ) specialization that collides with the
unsigned short one, producing errors such as:
redefinition of 'is_integral<unsigned short>'
visualc.hpp already guards against this by defining BOOST_NO_INTRINSIC_WCHAR_T
when _NATIVE_WCHAR_T_DEFINED is absent; clang.hpp was missing the equivalent
guard. Mirror the visualc.hpp behaviour here. The guard is scoped to _MSC_VER so
it is a no-op for native-wchar_t builds and for non-MSVC clang targets.
winstliu
approved these changes
Jul 1, 2026
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.
Why:
When clang targets MSVC compatibility (clang-cl, so _MSC_VER is defined) and is built with /Zc:wchar_t- , wchar_t is an alias for unsigned short rather than a distinct intrinsic type, and _NATIVE_WCHAR_T_DEFINED is not defined.
In that configuration Boost emits a separate is_integral<wchar_t> specialization that collides with the unsigned short one, producing errors such as:
redefinition of 'is_integral<unsigned short>'What:
visualc.hpp already guards against this by defining BOOST_NO_INTRINSIC_WCHAR_T when _NATIVE_WCHAR_T_DEFINED is absent; clang.hpp was missing the equivalent guard. Mirror the visualc.hpp behaviour here.
Validation:
Local build on consumer side with MSVC and Clang-cl passed