File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ wctrans_t wctrans(const char* property);
5959
6060_LIBCPP_BEGIN_NAMESPACE_STD
6161
62+ #if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H)
6263using ::wint_t _LIBCPP_USING_IF_EXISTS;
6364using ::wctrans_t _LIBCPP_USING_IF_EXISTS;
6465using ::wctype_t _LIBCPP_USING_IF_EXISTS;
@@ -80,6 +81,7 @@ using ::towlower _LIBCPP_USING_IF_EXISTS;
8081using ::towupper _LIBCPP_USING_IF_EXISTS;
8182using ::towctrans _LIBCPP_USING_IF_EXISTS;
8283using ::wctrans _LIBCPP_USING_IF_EXISTS;
84+ #endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
8385
8486_LIBCPP_END_NAMESPACE_STD
8587
Original file line number Diff line number Diff line change @@ -50,8 +50,18 @@ wctrans_t wctrans(const char* property);
5050#pragma GCC system_header
5151#endif
5252
53+ // TODO:
54+ // In the future, we should unconditionally include_next <wctype.h> here and instead
55+ // have a mode under which the library does not need libc++'s <wctype.h> or <cwctype>
56+ // at all (i.e. a mode without wchar_t). As it stands, we need to do that to completely
57+ // bypass the using declarations in <cwctype> when we did not include <wctype.h>.
58+ // Otherwise, a using declaration like `using ::wint_t` in <cwctype> will refer to
59+ // nothing (with using_if_exists), and if we include another header that defines one
60+ // of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists
61+ // will fail because it does not refer to the same declaration.
5362#if __has_include_next(<wctype.h>)
5463# include_next <wctype.h>
64+ # define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
5565#endif
5666
5767#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments