From caa450dcb9a2a9c236f510a85db060de2320b030 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 Nov 2019 20:07:33 +0100 Subject: [PATCH] - debugprintf --- source/build/src/sdlayer.cpp | 17 +++++++++++++++++ source/common/utility/printf.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index bf68f4d88..eb065a378 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -2061,3 +2061,20 @@ int32_t handleevents(void) } auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries. + +// +// debugprintf() -- sends a debug string to the debugger +// +void debugprintf(const char* f, ...) +{ + va_list va; + char buf[1024]; + + if (!IsDebuggerPresent()) return; + + va_start(va, f); + Bvsnprintf(buf, 1024, f, va); + va_end(va); + + OutputDebugStringA(buf); +} diff --git a/source/common/utility/printf.h b/source/common/utility/printf.h index 65c3538ae..a906b0a7c 100644 --- a/source/common/utility/printf.h +++ b/source/common/utility/printf.h @@ -69,3 +69,5 @@ inline void buildputs(const char *s) { PrintString(PRINT_HIGH, s); } + +void debugprintf(const char* f, ...); // Prints to the debugger's log.