From e69f6f710d14e6e42aacf6d27777fa5c34f43dae Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 13 Mar 2018 10:20:09 +0100 Subject: [PATCH] Disable stdout/stderr buffering on Windows In MSYS2 on Windows, the output is buffered by default. Disable buffering to print output immediately. Note that in cmd.exe, it still prints nothing. --- app/src/main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main.c b/app/src/main.c index 1f2164b6..01d9f175 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -233,6 +233,12 @@ static SDL_bool parse_args(struct args *args, int argc, char *argv[]) { } int main(int argc, char *argv[]) { +#ifdef __WINDOWS__ + // disable buffering, we want logs immediately + // even line buffering (setvbuf() with mode _IOLBF) is not sufficient + setbuf(stdout, NULL); + setbuf(stderr, NULL); +#endif struct args args = { .serial = NULL, .help = SDL_FALSE,