diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.cpp
similarity index 84%
rename from libc/stdio/stdio.c
rename to libc/stdio/stdio.cpp
index 1a12b6f9..efd9d3e3 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.cpp
@@ -17,23 +17,25 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- stdio/stdio.c
+ stdio/stdio.cpp
Sets up stdin, stdout, stderr.
*******************************************************************************/
#define __SORTIX_STDLIB_REDIRECTS 0
+
+#include
#include
#include
#include
-#include
+
#include "fdio.h"
-FILE* stdin;
-FILE* stdout;
-FILE* stderr;
+extern "C" { FILE* stdin; }
+extern "C" { FILE* stdout; }
+extern "C" { FILE* stderr; }
-int init_stdio()
+extern "C" int init_stdio()
{
// TODO: These calls require memory allocation and can fail - which we don't
// currently handle. How about declaring these as global objects and
@@ -45,27 +47,28 @@ int init_stdio()
return 0;
}
-int getchar(void)
+extern "C" int getchar(void)
{
return fgetc(stdin);
}
-int putchar(int c)
+extern "C" int putchar(int c)
{
return fputc(c, stdout);
}
-char* sortix_gets(void)
+extern "C" char* sortix_gets(void)
{
char* buf = NULL;
size_t n;
- if ( getline(&buf, &n, stdin) < 0 ) { return NULL; }
+ if ( getline(&buf, &n, stdin) < 0 )
+ return NULL;
size_t linelen = strlen(buf);
if ( linelen && buf[linelen-1] == '\n' ) { buf[linelen-1] = 0; }
return buf;
}
-int puts(const char* str)
+extern "C" int puts(const char* str)
{
return printf("%s\n", str) < 0 ? EOF : 1;
}