[clang] [libc] Fix wrapper headers if std=c99 is set (PR #168386)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 17 07:27:38 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-x86

Author: Dominik Adamski (DominikAdamski)

<details>
<summary>Changes</summary>

Declarations of stdio functions can be skipped for wrapper headers. Previous declarations of stdio functions caused compilation errors when the -std=c99 option is set.

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


1 Files Affected:

- (modified) clang/lib/Headers/llvm_libc_wrappers/stdio.h (+16-1) 


``````````diff
diff --git a/clang/lib/Headers/llvm_libc_wrappers/stdio.h b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
index 950f91b3763e8..99b58c1b23254 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/stdio.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/stdio.h
@@ -60,7 +60,22 @@
 
 #pragma omp begin declare target
 
-#include <llvm-libc-decls/stdio.h>
+#ifndef __LIBC_ATTRS
+#define __LIBC_ATTRS
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern FILE * stderr; __LIBC_ATTRS;
+
+extern FILE * stdin; __LIBC_ATTRS;
+
+extern FILE * stdout; __LIBC_ATTRS;
+
+#ifdef __cplusplus
+}
+#endif
 
 #pragma omp end declare target
 

``````````

</details>


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


More information about the cfe-commits mailing list