Skip to content

Fix Clang Boost wchar_t redefinition#539

Open
ruiji-shi wants to merge 1 commit into
boostorg:developfrom
ruiji-shi:user/ruishi/clang-cl-wchart-t-guard
Open

Fix Clang Boost wchar_t redefinition#539
ruiji-shi wants to merge 1 commit into
boostorg:developfrom
ruiji-shi:user/ruishi/clang-cl-wchart-t-guard

Conversation

@ruiji-shi

Copy link
Copy Markdown

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

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.
@ruiji-shi ruiji-shi changed the title Define BOOST_NO_INTRINSIC_WCHAR_T for clang-cl with non-native wchar_t Fix Clang Boost wchar_t redefinition Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants