From f0c6f08beac2ad6699af7707c51f9049db1b18c1 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 3 May 2020 19:04:04 -0400 Subject: got tests to work on windows (fixed some problems with them) --- std/io.toc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'std') 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) { -- cgit v1.2.3