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

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.

>From 05677f564bb075af55306e86d27c62139d05f7bf Mon Sep 17 00:00:00 2001
From: Dominik Adamski <[email protected]>
Date: Mon, 17 Nov 2025 09:10:25 -0600
Subject: [PATCH] [libc] Fix wrapper headers if std=c99 is set

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.
---
 clang/lib/Headers/llvm_libc_wrappers/stdio.h | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

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
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to