diff options
author | quou <quou@disroot.org> | 2025-02-08 21:57:24 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2025-02-08 21:58:09 +1100 |
commit | 44bf93739d07ba65706464b4031d779a995ebbfd (patch) | |
tree | eb7b436de2a63e7d94f2fb58c022fc35984d1fca | |
parent | d80e32ff73dbd8dd8fa1bb1a07453daecb49603d (diff) |
Check if debugger is attached and if it isn't then use normal printf
-rw-r--r-- | qstd/plat.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/qstd/plat.c b/qstd/plat.c index b34e8cb..d1f15e7 100644 --- a/qstd/plat.c +++ b/qstd/plat.c @@ -128,8 +128,9 @@ uint64_t get_time(void) { #include <stdio.h> #include <windows.h> -#include <stdio.h> +#include <debugapi.h> #include <io.h> +#include <stdio.h> int imp_assert( int val, @@ -156,7 +157,10 @@ void print(const char* fmt, ...) { va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); - OutputDebugStringA(buf); + if (IsDebuggerPresent()) + OutputDebugStringA(buf); + else + printf("%s\n", buf); } void print_err(const char* fmt, ...) { @@ -165,7 +169,10 @@ void print_err(const char* fmt, ...) { va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); - OutputDebugStringA(buf); + if (IsDebuggerPresent()) + OutputDebugStringA(buf); + else + printf("%s\n", buf); } void print_war(const char* fmt, ...) { @@ -174,7 +181,10 @@ void print_war(const char* fmt, ...) { va_start(args, fmt); vsprintf(buf, fmt, args); va_end(args); - OutputDebugStringA(buf); + if (IsDebuggerPresent()) + OutputDebugStringA(buf); + else + printf("%s\n", buf); } void pbreak(int code) { |