[libcxx-commits] [PATCH] D151740: [libc++] Include "bits/alltypes.h" to provide mbstate_t when using musl libc
Pengxuan Zheng via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 30 11:24:07 PDT 2023
pzheng created this revision.
pzheng added reviewers: iana, ldionne, Mordante, philnik.
Herald added a project: All.
pzheng requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
With D148542 <https://reviews.llvm.org/D148542>, we ran into the following libc++ build error when using musl libc.
.../musl/include/bits/alltypes.h:354:16:
error: definition of type '__mbstate_t' conflicts with typedef of the same name
typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
^
.../sysroot/usr/include/bits/types/__mbstate_t.h:21:3: note: '__mbstate_t' declared here
} __mbstate_t;
^
1 error generated.
This is because the mbstate_t definition in musl libc conflicts with the one
from "bits/types/mbstate_t.h", and this patch attempts to fix this build issue
when musl libc is used.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151740
Files:
libcxx/include/__mbstate_t.h
Index: libcxx/include/__mbstate_t.h
===================================================================
--- libcxx/include/__mbstate_t.h
+++ libcxx/include/__mbstate_t.h
@@ -35,7 +35,10 @@
# define __CORRECT_ISO_CPP_WCHAR_H_PROTO
#endif
-#if __has_include(<bits/types/mbstate_t.h>)
+#if defined(_LIBCPP_HAS_MUSL_LIBC)
+# define __NEED_mbstate_t
+# include <bits/alltypes.h>
+#elif __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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151740.526727.patch
Type: text/x-patch
Size: 598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230530/3801ae2a/attachment.bin>
More information about the libcxx-commits
mailing list