summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/io.toc13
1 files changed, 11 insertions, 2 deletions
diff --git a/std/io.toc b/std/io.toc
index c3d8f71..a56ef55 100644
--- a/std/io.toc
+++ b/std/io.toc
@@ -1,13 +1,22 @@
+/* TODO: use write / WriteFile */
+
#include "std/base.toc";
putchar ::= #foreign("putchar", libc) fn(#C int) #C int;
toc_putchar ::= fn(x: char) {
putchar(x as #C int);
}
-fwrite ::= #foreign("fwrite", libc) fn(#C &"const void", #C size_t, #C size_t, #C &"FILE") #C size_t;
+
+/*
+unfortunately, we can't use fwrite because MSVC doesn't like it when you
+use a file handle that's not from the DLL. (i.e. you can't pass your stdout
+to the imported version of fwrite)
+*/
writes ::= fn(x: []char) {
- fwrite(&x[0], 1, x.len as #C size_t, #builtin("stdout"));
+ for c := x {
+ toc_putchar(c);
+ }
}
puts ::= fn(x: []char) {