diff --git a/libc/src/__support/File/gpu/file.cpp b/libc/src/__support/File/gpu/file.cpp --- a/libc/src/__support/File/gpu/file.cpp +++ b/libc/src/__support/File/gpu/file.cpp @@ -97,3 +97,10 @@ File *stderr = &StdErr; } // namespace __llvm_libc + +// Provide the external defintitions of the standard IO streams. +extern "C" { +FILE *stdin = reinterpret_cast(&__llvm_libc::StdIn); +FILE *stderr = reinterpret_cast(&__llvm_libc::StdErr); +FILE *stdout = reinterpret_cast(&__llvm_libc::StdOut); +} diff --git a/libc/src/__support/File/linux/file.cpp b/libc/src/__support/File/linux/file.cpp --- a/libc/src/__support/File/linux/file.cpp +++ b/libc/src/__support/File/linux/file.cpp @@ -183,3 +183,10 @@ File *stderr = &StdErr; } // namespace __llvm_libc + +// Provide the external defintitions of the standard IO streams. +extern "C" { +FILE *stdin = reinterpret_cast(&__llvm_libc::StdIn); +FILE *stderr = reinterpret_cast(&__llvm_libc::StdErr); +FILE *stdout = reinterpret_cast(&__llvm_libc::StdOut); +} diff --git a/libc/src/stdio/stderr.cpp b/libc/src/stdio/stderr.cpp --- a/libc/src/stdio/stderr.cpp +++ b/libc/src/stdio/stderr.cpp @@ -10,6 +10,4 @@ #include -extern "C" { -FILE *stderr = reinterpret_cast(__llvm_libc::stderr); -} +extern "C" FILE *stderr; diff --git a/libc/src/stdio/stdin.cpp b/libc/src/stdio/stdin.cpp --- a/libc/src/stdio/stdin.cpp +++ b/libc/src/stdio/stdin.cpp @@ -10,6 +10,4 @@ #include -extern "C" { -FILE *stdin = reinterpret_cast(__llvm_libc::stdin); -} +extern "C" FILE *stdin; diff --git a/libc/src/stdio/stdout.cpp b/libc/src/stdio/stdout.cpp --- a/libc/src/stdio/stdout.cpp +++ b/libc/src/stdio/stdout.cpp @@ -10,6 +10,4 @@ #include -extern "C" { -FILE *stdout = reinterpret_cast(__llvm_libc::stdout); -} +extern "C" FILE *stdout;