Skip to content

[libc++] Only include the system <stdint.h> and <locale.h> if they exist #115017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2024

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Nov 5, 2024

Prior to aa7f377, 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.

Prior to aa7f377, 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.
@ldionne ldionne requested a review from a team as a code owner November 5, 2024 16:07
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2024

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

Prior to aa7f377, 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.


Full diff: https://github.com/llvm/llvm-project/pull/115017.diff

2 Files Affected:

  • (modified) libcxx/include/clocale (+3-1)
  • (modified) libcxx/include/cstdint (+3-1)
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

@ldionne ldionne merged commit f1f5220 into llvm:main Nov 6, 2024
65 checks passed
@ldionne ldionne deleted the review/fix-locale-inclusion branch November 6, 2024 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants