Skip to content

Commit 2689a99

Browse files
committed
[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 relying on wide character functionality in the C library. C90 amendment 1 says that this type is to be visible through wchar.h. That header file is provided by the C standard library even when that library is not implementing wchar functions (such as newlib with --nano-formatted-io). Since we have a way to conditionally include <wchar.h> only if it exists, we should rely on the fact that if it exists, it will provide mbstate_t.
1 parent f3a1d55 commit 2689a99

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libcxx/include/__mbstate_t.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
# include <bits/types/mbstate_t.h> // works on most Unixes
4444
#elif __has_include(<sys/_types/_mbstate_t.h>)
4545
# include <sys/_types/_mbstate_t.h> // works on Darwin
46-
#elif _LIBCPP_HAS_WIDE_CHARACTERS && __has_include_next(<wchar.h>)
47-
# include_next <wchar.h> // fall back to the C standard provider of mbstate_t
46+
#elif __has_include_next(<wchar.h>)
47+
# include_next <wchar.h> // user the C standard provider of mbstate_t if present
4848
#elif __has_include_next(<uchar.h>)
49-
# include_next <uchar.h> // <uchar.h> is also required to make mbstate_t visible
49+
# include_next <uchar.h> // <uchar.h> can alternatively provide mbstate_t
5050
#else
51-
# error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
51+
# error "We don't know how to get the definition of mbstate_t on your platform."
5252
#endif
5353

5454
#endif // _LIBCPP___MBSTATE_T_H

0 commit comments

Comments
 (0)