Skip to content

Commit 53e43a5

Browse files
committed
[libc++] Don't error when including <wchar.h> or <wctype.h> without wide character support
Instead, make the headers empty like we do for all the other carve-outs.
1 parent acf90fd commit 53e43a5

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

libcxx/include/wchar.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
108108
# include <__config>
109109
# include <stddef.h>
110110

111-
# if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
112-
# error \
113-
"The <wchar.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled"
114-
# endif
115-
116111
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
117112
# pragma GCC system_header
118113
# endif
@@ -142,7 +137,8 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
142137
# endif
143138
# endif
144139

145-
# if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
140+
# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
141+
# if defined(__cplusplus) && !defined(_LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS) && defined(_LIBCPP_PREFERRED_OVERLOAD)
146142
extern "C++" {
147143
inline _LIBCPP_HIDE_FROM_ABI wchar_t* __libcpp_wcschr(const wchar_t* __s, wchar_t __c) {
148144
return (wchar_t*)wcschr(__s, __c);
@@ -197,15 +193,16 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD wchar_t* wmemchr(wchar_t
197193
return __libcpp_wmemchr(__s, __c, __n);
198194
}
199195
}
200-
# endif
196+
# endif
201197

202-
# if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))
198+
# if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__))
203199
extern "C" {
204200
size_t mbsnrtowcs(
205201
wchar_t* __restrict __dst, const char** __restrict __src, size_t __nmc, size_t __len, mbstate_t* __restrict __ps);
206202
size_t wcsnrtombs(
207203
char* __restrict __dst, const wchar_t** __restrict __src, size_t __nwc, size_t __len, mbstate_t* __restrict __ps);
208204
} // extern "C"
209-
# endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)
205+
# endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__)
206+
# endif // !_LIBCPP_HAS_NO_WIDE_CHARACTERS
210207

211208
#endif // _LIBCPP_WCHAR_H

libcxx/include/wctype.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ wctrans_t wctrans(const char* property);
4646

4747
#include <__config>
4848

49-
#if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
50-
# error \
51-
"The <wctype.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled"
52-
#endif
53-
5449
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5550
# pragma GCC system_header
5651
#endif

libcxx/test/std/depr/depr.c.headers/wctype_h.compile.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// XFAIL: no-wide-characters
9+
// UNSUPPORTED: no-wide-characters
1010

1111
// <wctype.h>
1212

libcxx/test/std/strings/c.strings/cwctype.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// <cwctype>
1010

11-
// XFAIL: no-wide-characters
11+
// UNSUPPORTED: no-wide-characters
1212

1313
#include <cwctype>
1414
#include <type_traits>

0 commit comments

Comments
 (0)