|
7 | 7 | //
|
8 | 8 | //===----------------------------------------------------------------------===//
|
9 | 9 |
|
10 |
| -#if defined(__need_wint_t) || defined(__need_mbstate_t) |
11 |
| - |
12 |
| -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
13 |
| -# pragma GCC system_header |
14 |
| -# endif |
15 |
| - |
16 |
| -# include_next <wchar.h> |
17 |
| - |
18 |
| -#elif !defined(_LIBCPP_WCHAR_H) |
19 |
| -# define _LIBCPP_WCHAR_H |
20 |
| - |
21 | 10 | /*
|
22 | 11 | wchar.h synopsis
|
23 | 12 |
|
@@ -105,25 +94,35 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
|
105 | 94 |
|
106 | 95 | */
|
107 | 96 |
|
108 |
| -# if 0 |
109 |
| -# else // 0 |
110 |
| -# include <__config> |
111 |
| -# include <stddef.h> |
| 97 | +#if 0 |
| 98 | +#else // 0 |
| 99 | +# include <__config> |
112 | 100 |
|
113 |
| -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
114 |
| -# pragma GCC system_header |
115 |
| -# endif |
| 101 | +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 102 | +# pragma GCC system_header |
| 103 | +# endif |
116 | 104 |
|
117 | 105 | // We define this here to support older versions of glibc <wchar.h> that do
|
118 | 106 | // not define this for clang.
|
119 |
| -# ifdef __cplusplus |
120 |
| -# define __CORRECT_ISO_CPP_WCHAR_H_PROTO |
121 |
| -# endif |
| 107 | +# if defined(__cplusplus) && !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO) |
| 108 | +# define __CORRECT_ISO_CPP_WCHAR_H_PROTO |
| 109 | +# endif |
| 110 | + |
| 111 | +// The inclusion of the system's <wchar.h> is intentionally done once outside of any include |
| 112 | +// guards because some code expects to be able to include the underlying system header multiple |
| 113 | +// times to get different definitions based on the macros that are set before inclusion. |
| 114 | +# if __has_include_next(<wchar.h>) |
| 115 | +# include_next <wchar.h> |
| 116 | +# endif |
| 117 | + |
| 118 | +# ifndef _LIBCPP_WCHAR_H |
| 119 | +# define _LIBCPP_WCHAR_H |
| 120 | + |
| 121 | +# include <__mbstate_t.h> // provide mbstate_t |
| 122 | +# include <stddef.h> // provide size_t |
122 | 123 |
|
123 | 124 | # if __has_include_next(<wchar.h>)
|
124 | 125 | # include_next <wchar.h>
|
125 |
| -# else |
126 |
| -# include <__mbstate_t.h> // make sure we have mbstate_t regardless of the existence of <wchar.h> |
127 | 126 | # endif
|
128 | 127 |
|
129 | 128 | // Determine whether we have const-correct overloads for wcschr and friends.
|
|
0 commit comments