[libcxx-commits] [libcxx] [libcxx]support freestanding libc++ (PR #208900)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 12 10:26:02 PDT 2026


================
@@ -60,11 +60,49 @@ size_t strlen(const char* s);
 #    pragma GCC system_header
 #  endif
 
+#  include <stddef.h>
 #  if __has_include_next(<string.h>)
 #    include_next <string.h>
-#  endif
+#  else
+#    ifndef __cplusplus
+extern "C" {
+#    endif
 
-#  include <stddef.h>
+/*
+We offer declarations for these C functions,
+leaving the implementations to be handled by users.
+*/
+
----------------
arhwx wrote:

Libc++ can be used with GCC, and the macro won't expand to the attribute if it isn't supported, so it won't result in syntax errors; you can see the macro definition in libc++:
```cpp
#if __has_attribute(__using_if_exists__)
#  define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
#else
#  define _LIBCPP_USING_IF_EXISTS
#endif
```

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


More information about the libcxx-commits mailing list