diff --git a/libcxx/include/cwctype b/libcxx/include/cwctype --- a/libcxx/include/cwctype +++ b/libcxx/include/cwctype @@ -59,6 +59,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H) using ::wint_t _LIBCPP_USING_IF_EXISTS; using ::wctrans_t _LIBCPP_USING_IF_EXISTS; using ::wctype_t _LIBCPP_USING_IF_EXISTS; @@ -80,6 +81,7 @@ using ::towupper _LIBCPP_USING_IF_EXISTS; using ::towctrans _LIBCPP_USING_IF_EXISTS; using ::wctrans _LIBCPP_USING_IF_EXISTS; +#endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/wctype.h b/libcxx/include/wctype.h --- a/libcxx/include/wctype.h +++ b/libcxx/include/wctype.h @@ -50,8 +50,18 @@ #pragma GCC system_header #endif +// TODO: +// In the future, we should unconditionally include_next here and instead +// have a mode under which the library does not need libc++'s or +// at all (i.e. a mode without wchar_t). As it stands, we need to do that to completely +// bypass the using declarations in when we did not include . +// Otherwise, a using declaration like `using ::wint_t` in will refer to +// nothing (with using_if_exists), and if we include another header that defines one +// of these declarations (e.g. ), the second `using ::wint_t` with using_if_exists +// will fail because it does not refer to the same declaration. #if __has_include_next() # include_next +# define _LIBCPP_INCLUDED_WCTYPE_H #endif #ifdef __cplusplus