diff --git a/libcxx/include/__mbstate_t.h b/libcxx/include/__mbstate_t.h --- a/libcxx/include/__mbstate_t.h +++ b/libcxx/include/__mbstate_t.h @@ -16,29 +16,22 @@ # pragma GCC system_header #endif -// TODO(ldionne): -// The goal of this header is to provide mbstate_t without having to pull in -// or . This is necessary because we need that type even -// when we don't have (or try to provide) support for wchar_t, because several +// The goal of this header is to provide mbstate_t without requiring all of +// or , which is not always available. Indeed, we need +// that type even when we don't have support for wchar_t, because several // types like std::fpos are defined in terms of mbstate_t. // -// This is a gruesome hack, but I don't know how to make it cleaner for -// the time being. +// This does not define std::mbstate_t -- this only brings in the declaration +// in the global namespace. -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -# include // for mbstate_t -#elif __has_include() +#if __has_include() # include // works on most Unixes #elif __has_include() # include // works on Darwin +#elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && __has_include_next() +# include_next #else # error "The library was configured without support for wide-characters, but we don't know how to get the definition of mbstate_t without on your platform." #endif -_LIBCPP_BEGIN_NAMESPACE_STD - -using ::mbstate_t _LIBCPP_USING_IF_EXISTS; - -_LIBCPP_END_NAMESPACE_STD - #endif // _LIBCPP___MBSTATE_T_H diff --git a/libcxx/include/uchar.h b/libcxx/include/uchar.h --- a/libcxx/include/uchar.h +++ b/libcxx/include/uchar.h @@ -42,10 +42,12 @@ // Some platforms don't implement and we don't want to give a hard // error on those platforms. When the platform doesn't provide , at -// least include so we get the declaration for size_t. +// least include so we get the declaration for size_t, and try to +// get the declaration of mbstate_t too. #if __has_include_next() # include_next #else +# include <__mbstate_t.h> # include #endif diff --git a/libcxx/include/wchar.h b/libcxx/include/wchar.h --- a/libcxx/include/wchar.h +++ b/libcxx/include/wchar.h @@ -122,6 +122,8 @@ # if __has_include_next() # include_next +# else +# include <__mbstate_t.h> # endif // Determine whether we have const-correct overloads for wcschr and friends.