Skip to content

Commit 75108a5

Browse files
authored
line buffered cpp stdout (#1199)
1 parent dd050c0 commit 75108a5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/hx/StdLibs.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void __hxcpp_stdlibs_boot()
282282
// It does not cause fread to return immediately - as perhaps desired.
283283
// But it does cause some new-line characters to be lost.
284284
//setbuf(stdin, 0);
285-
setbuf(stdout, 0);
285+
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
286286
setbuf(stderr, 0);
287287
}
288288

@@ -307,7 +307,7 @@ void __trace(Dynamic inObj, Dynamic info)
307307
//PRINTF("%s:%d: %s\n", filename, line, text.raw_ptr() ? text.out_str(&convertBuf) : "null");
308308
PRINTF("%s:%d: %s\n", filename, line, text.raw_ptr() ? text.out_str(&convertBuf) : "null");
309309
}
310-
310+
fflush(stdout);
311311
}
312312

313313
void __hxcpp_exit(int inExitCode)
@@ -589,6 +589,7 @@ void __hxcpp_println_string(const String &inV)
589589
{
590590
hx::strbuf convertBuf;
591591
PRINTF("%s\n", inV.out_str(&convertBuf));
592+
fflush(stdout);
592593
}
593594

594595

0 commit comments

Comments
 (0)