[libcxx-commits] [libcxx] fef23e8 - [libc++] Include "bits/alltypes.h" to provide mbstate_t when using musl libc
Pengxuan Zheng via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 30 17:59:47 PDT 2023
Author: Pengxuan Zheng
Date: 2023-05-30T17:59:32-07:00
New Revision: fef23e8d871add8d885d335e4586a9fa420c1171
URL: https://github.com/llvm/llvm-project/commit/fef23e8d871add8d885d335e4586a9fa420c1171
DIFF: https://github.com/llvm/llvm-project/commit/fef23e8d871add8d885d335e4586a9fa420c1171.diff
LOG: [libc++] Include "bits/alltypes.h" to provide mbstate_t when using musl libc
With 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.
Reviewed By: iana
Differential Revision: https://reviews.llvm.org/D151740
Added:
Modified:
libcxx/include/__mbstate_t.h
Removed:
################################################################################
diff --git a/libcxx/include/__mbstate_t.h b/libcxx/include/__mbstate_t.h
index 000af71119f4..2b9e719b1f2e 100644
--- a/libcxx/include/__mbstate_t.h
+++ b/libcxx/include/__mbstate_t.h
@@ -35,7 +35,11 @@
# 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>
+# undef __NEED_mbstate_t
+#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
More information about the libcxx-commits
mailing list