[libcxx-commits] [PATCH] D150322: [NFC] Move __CORRECT_ISO_CPP_WCHAR_H_PROTO closer to wchar.h include

Jordan Rupprecht via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 10 16:02:26 PDT 2023


rupprecht updated this revision to Diff 521131.
rupprecht added a comment.

- Fix some indentation


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150322/new/

https://reviews.llvm.org/D150322

Files:
  libcxx/include/__mbstate_t.h
  libcxx/include/wchar.h


Index: libcxx/include/wchar.h
===================================================================
--- libcxx/include/wchar.h
+++ libcxx/include/wchar.h
@@ -116,17 +116,16 @@
 #  pragma GCC system_header
 #endif
 
+#if __has_include_next(<wchar.h>)
 // We define this here to support older versions of glibc <wchar.h> that do
 // not define this for clang.
-#ifdef __cplusplus
-#define __CORRECT_ISO_CPP_WCHAR_H_PROTO
-#endif
-
-#  if __has_include_next(<wchar.h>)
-#    include_next <wchar.h>
-#  else
-#    include <__mbstate_t.h> // make sure we have mbstate_t regardless of the existence of <wchar.h>
+#  ifdef __cplusplus
+#    define __CORRECT_ISO_CPP_WCHAR_H_PROTO
 #  endif
+#  include_next <wchar.h>
+#else
+#  include <__mbstate_t.h> // make sure we have mbstate_t regardless of the existence of <wchar.h>
+#endif
 
 // Determine whether we have const-correct overloads for wcschr and friends.
 #if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
Index: libcxx/include/__mbstate_t.h
===================================================================
--- libcxx/include/__mbstate_t.h
+++ libcxx/include/__mbstate_t.h
@@ -27,24 +27,24 @@
 // This does not define std::mbstate_t -- this only brings in the declaration
 // in the global namespace.
 
+#if __has_include(<bits/types/mbstate_t.h>)
+#  include <bits/types/mbstate_t.h> // works on most Unixes
+#elif __has_include(<sys/_types/_mbstate_t.h>)
+#  include <sys/_types/_mbstate_t.h> // works on Darwin
+#elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && __has_include_next(<wchar.h>)
+// Some older versions of <wchar.h> do not define this for clang, so we do it ourselves.
 // We define this here to support older versions of glibc <wchar.h> that do
 // not define this for clang. This is also set in libc++'s <wchar.h> header,
 // and we need to do so here too to avoid a different function signature given
 // a different include order.
-#ifdef __cplusplus
-#  define __CORRECT_ISO_CPP_WCHAR_H_PROTO
-#endif
-
-#if __has_include(<bits/types/mbstate_t.h>)
-#   include <bits/types/mbstate_t.h> // works on most Unixes
-#elif __has_include(<sys/_types/_mbstate_t.h>)
-#   include <sys/_types/_mbstate_t.h> // works on Darwin
-#elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) && __has_include_next(<wchar.h>)
-#   include_next <wchar.h> // fall back to the C standard provider of mbstate_t
+#  ifdef __cplusplus
+#    define __CORRECT_ISO_CPP_WCHAR_H_PROTO
+#  endif
+#  include_next <wchar.h> // fall back to the C standard provider of mbstate_t
 #elif __has_include_next(<uchar.h>)
-#   include_next <uchar.h> // <uchar.h> is also required to make mbstate_t visible
+#  include_next <uchar.h> // <uchar.h> is also required to make mbstate_t visible
 #else
-#   error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
+#  error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."
 #endif
 
 #endif // _LIBCPP___MBSTATE_T_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150322.521131.patch
Type: text/x-patch
Size: 2962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230510/a44b712b/attachment-0001.bin>


More information about the libcxx-commits mailing list