[libcxx-commits] [libcxx] [libcxx] Do not redeclare `lgamma_r` when targeting the LLVM C library (PR #102036)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 15 13:39:07 PST 2025


================
@@ -30,15 +30,18 @@
 // ... add new file formats here ...
 #endif
 
-// Need to detect which libc we're using if we're on Linux.
-#if defined(__linux__)
+// To detect which libc we're using
+#if __has_include(<features.h>)
----------------
ldionne wrote:

When pre-qualifying LLVM 20, we just found out that this breaks some code. Indeed, folks are free to have a header named `<features.h>` available on their include paths, and in fact it seems not uncommon to have that. So the `__has_include(<features.h>)` is going to lie, and the `#include <features.h>` is going to pick up the wrong one anyway.

We'd need to find another header we can include to provide this version macro. Since C lacks a standardized header to provide version stuff (what a shame), we often rely on using some minimal header like `<iso646.h>` to get implementation-specific values. That should work for glibc, and llvm-libc could be changed to provide a `<iso646.h>` header. Also, all of llvm-libc's headers should define the feature macros like `__LLVM_LIBC__`, which I think is not the case right now.

CCing @var-const @jhuber6 @michaelrj-google 

https://github.com/llvm/llvm-project/pull/102036


More information about the libcxx-commits mailing list