summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-05-03 19:04:04 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-05-03 19:04:04 -0400
commitf0c6f08beac2ad6699af7707c51f9049db1b18c1 (patch)
tree6771d09818287f0bcdd519ef81efe2446ac000df /std
parent9661c9839d6635181b81e0a1061dfa566f7660fe (diff)
got tests to work on windows (fixed some problems with them)
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) {