Skip to content

Commit

Permalink
hosted: Use unbuffered stdout on Windows
Browse files Browse the repository at this point in the history
* Line-buffered mode is unsupported on Windows libc,
  and 4k-buffered mode is not interactive enough.
* Disable buffering completely as an alternative to sprinkling tons of fflush() calls.
  • Loading branch information
ALTracer committed Jul 13, 2024
1 parent 117028d commit c4c763e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/platforms/hosted/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ void platform_init(int argc, char **argv)
{
#if defined(_WIN32) || defined(__CYGWIN__)
SetConsoleOutputCP(CP_UTF8);
if (setvbuf(stdout, NULL, _IONBF, 0) < 0) {
int err = errno;
fprintf(stderr, "%s: %s returns %s\n", __func__, "setvbuf()", strerror(err));
}
#endif
cl_init(&cl_opts, argc, argv);
atexit(exit_function);
Expand Down

0 comments on commit c4c763e

Please sign in to comment.