[PATCH 1/2] newlib: don't #include_next <limits.h> for clang
H. Peter Anvin
hpa@zytor.com
Thu Dec 3 21:40:11 GMT 2026
The clang version of <limits.h> can have libc dependencies; for
example, it relies on __GLIBC_USE(). Pulling in the host or other-libc
headers is not a good idea so use the internal <limits.h> only for
clang.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
newlib/libc/include/limits.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/newlib/libc/include/limits.h b/newlib/libc/include/limits.h
index 893f10834f6c..7d1966dac070 100644
--- a/newlib/libc/include/limits.h
+++ b/newlib/libc/include/limits.h
@@ -17,8 +17,9 @@
# endif
/* if do not have #include_next support, then we
- have to define the limits here. */
-# if !defined __GNUC__ || __GNUC__ < 2
+ have to define the limits here. clangs <limits.h>
+ may have system dependencies, so don't use it. */
+# if !defined __GNUC__ || defined __clang__ || __GNUC__ < 2
# ifndef _LIMITS_H
# define _LIMITS_H 1
@@ -127,7 +128,7 @@
#endif /* !_LIBC_LIMITS_H_ */
-#if defined __GNUC__ && !defined _GCC_LIMITS_H_
+#if defined __GNUC__ && !defined _GCC_LIMITS_H_ && !defined __clang__
/* `_GCC_LIMITS_H_' is what GCC's file defines. */
# include_next <limits.h>
#endif /* __GNUC__ && !_GCC_LIMITS_H_ */
--
2.56.1
More information about the Newlib
mailing list