From de6e5587875d77d093824ab30c58dfe3b72885a2 Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Wed, 12 Feb 2025 15:17:23 +0100 Subject: [PATCH] [libc++] Do not guard inclusion of wchar.h with _LIBCPP_HAS_WIDE_CHARACTERS mbstate_t needs to be visible to libcpp, even when it is not providing wide character functionality (i.e. _LIBCPP_HAS_WIDE_CHARACTERS is turned off) and thus not using any of the C library's wide character functions. There are C libraries (such as newlib-nano/nanolib/picolibc) which do provide their definition of mbstate_t in even though they do not come with wide character functions. Since there is a way to conditionally include the C library's only if it exists, we should rely on the fact that if it exists, it will provide mbstate_t. Removing this guard will allow using libc++ on top of newlib-nano/picolibc while not breaking the cases where it is used on top of a C library which doesn't provide (since it would then still go look for or error out). --- libcxx/include/__mbstate_t.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libcxx/include/__mbstate_t.h b/libcxx/include/__mbstate_t.h index e013384454b41..c23ea7113ca70 100644 --- a/libcxx/include/__mbstate_t.h +++ b/libcxx/include/__mbstate_t.h @@ -43,12 +43,12 @@ # include // works on most Unixes #elif __has_include() # include // works on Darwin -#elif _LIBCPP_HAS_WIDE_CHARACTERS && __has_include_next() -# include_next // fall back to the C standard provider of mbstate_t +#elif __has_include_next() +# include_next // use the C standard provider of mbstate_t if present #elif __has_include_next() -# include_next // is also required to make mbstate_t visible +# include_next // Try in absence of for mbstate_t #else -# error "We don't know how to get the definition of mbstate_t without on your platform." +# error "We don't know how to get the definition of mbstate_t on your platform." #endif #endif // _LIBCPP___MBSTATE_T_H