[PATCH 2/2] newlib: fix compiling stdbit_internal.h with clang
H. Peter Anvin
hpa@zytor.com
Thu Dec 3 21:40:12 GMT 2026
clang uses __CHAR_BIT__ and __LLONG_WIDTH__ rather than
__SCHAR_WIDTH__ and __LONG_LONG_WIDTH__.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
newlib/libc/stdbit/stdbit_internal.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/newlib/libc/stdbit/stdbit_internal.h b/newlib/libc/stdbit/stdbit_internal.h
index a0a2e556db6b..48103878c2a0 100644
--- a/newlib/libc/stdbit/stdbit_internal.h
+++ b/newlib/libc/stdbit/stdbit_internal.h
@@ -25,7 +25,11 @@
#define STDBIT_INTERNAL_h
#ifndef UCHAR_WIDTH
+#ifdef __SCHAR_WIDTH__ /* gcc */
#define UCHAR_WIDTH __SCHAR_WIDTH__
+#elif defined __CHAR_BIT__ /* clang */
+#define UCHAR_WIDTH __CHAR_BIT__
+#endif
#endif
#ifndef USHRT_WIDTH
@@ -41,7 +45,11 @@
#endif
#ifndef ULLONG_WIDTH
+#ifdef __LONG_LONG_WIDTH /* gcc */
#define ULLONG_WIDTH __LONG_LONG_WIDTH__
+#elif defined __LLONG_WIDTH__ /* clang */
+#define ULLONG_WIDTH __LLONG_WIDTH__
+#endif
#endif
#endif
--
2.56.1
More information about the Newlib
mailing list