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

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jul 12 08:27:55 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:

These declarations omit `strcoll`, `strxfrm`, and `strerror`, that is fine on Clang since `<cstring>` can handle it through `_LIBCPP_USING_IF_EXISTS`, but GCC does not support this attribute, so including `<cstring>` fails to compile.

Note I only checked `<string.h>`/`<cstring>`, but this can apply to the other headers as well; if Clang only is intentional, a clear `#error` for other compilers would explain the failure.

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


More information about the libcxx-commits mailing list