[libcxx-commits] [libcxx] [libc++] Only include the system <stdint.h> and <locale.h> if they exist (PR #115017)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 5 08:08:03 PST 2024
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/115017
Prior to aa7f377c96, we only did an #include_next of those system headers if they existed. After removing those headers from libc++, we started assuming that the system provided the headers because we unconditionally started including them. This patch fixes that.
>From 94bc56239c080ee0e76d2004967e50af9201dddd Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 5 Nov 2024 11:05:50 -0500
Subject: [PATCH] [libc++] Only include the system <stdint.h> and <locale.h> if
they exist
Prior to aa7f377c96, we only did an #include_next of those system
headers if they existed. After removing those headers from libc++,
we started assuming that the system provided the headers because we
unconditionally started including them. This patch fixes that.
---
libcxx/include/clocale | 4 +++-
libcxx/include/cstdint | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/clocale b/libcxx/include/clocale
index 4d53aa7eb29b29..a82a166712c26e 100644
--- a/libcxx/include/clocale
+++ b/libcxx/include/clocale
@@ -36,7 +36,9 @@ lconv* localeconv();
#include <__config>
-#include <locale.h>
+#if __has_include(<locale.h>)
+# include <locale.h>
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/cstdint b/libcxx/include/cstdint
index 9c9b2323d06ea9..b3167c33f24778 100644
--- a/libcxx/include/cstdint
+++ b/libcxx/include/cstdint
@@ -142,7 +142,9 @@ Types:
#include <__config>
-#include <stdint.h>
+#if __has_include(<stdint.h>)
+# include <stdint.h>
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
More information about the libcxx-commits
mailing list