[libcxx-commits] [libcxx] [libc++] Guard include of <features.h> with __has_include (PR #127691)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 18 11:41:38 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Louis Dionne (ldionne)
<details>
<summary>Changes</summary>
Some configurations define __AMDGPU__ or __NVPTX__ on platforms that don't provide <features.h>, such as CUDA on Mac.
---
Full diff: https://github.com/llvm/llvm-project/pull/127691.diff
1 Files Affected:
- (modified) libcxx/include/__configuration/platform.h (+8-6)
``````````diff
diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index cff99376ee24b..8d0f8f63f5213 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -32,12 +32,14 @@
// Need to detect which libc we're using if we're on Linux.
#if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)
-# include <features.h>
-# if defined(__GLIBC_PREREQ)
-# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
-# else
-# define _LIBCPP_GLIBC_PREREQ(a, b) 0
-# endif // defined(__GLIBC_PREREQ)
+# if __has_include(<features.h>)
+# include <features.h>
+# if defined(__GLIBC_PREREQ)
+# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
+# else
+# define _LIBCPP_GLIBC_PREREQ(a, b) 0
+# endif // defined(__GLIBC_PREREQ)
+# endif
#endif
#ifndef __BYTE_ORDER__
``````````
</details>
https://github.com/llvm/llvm-project/pull/127691
More information about the libcxx-commits
mailing list