From f191adc1fb899115915b5f0bf41bf32de518bc51 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Wed, 3 Jul 2013 16:48:23 +0100 Subject: Update Memento to output to debug window on windows. Windows is stupid and doesn't display stderr/stdout in the debugger. Update Memento so that messages will appear there too. --- source/fitz/memento.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source/fitz/memento.c') diff --git a/source/fitz/memento.c b/source/fitz/memento.c index 6a159f10..47aded31 100644 --- a/source/fitz/memento.c +++ b/source/fitz/memento.c @@ -61,6 +61,31 @@ android_fprintf(FILE *file, const char *fmt, ...) #define MEMENTO_STACKTRACE_METHOD 0 #endif +#ifdef _WIN32 +#include + +static int +windows_fprintf(FILE *file, const char *fmt, ...) +{ + va_list args; + char text[4096]; + int ret; + + va_start(args, fmt); + ret = vfprintf(file, fmt, args); + va_end(args); + + va_start(args, fmt); + vsnprintf(text, 4096, fmt, args); + OutputDebugStringA(text); + va_end(args); + + return ret; +} + +#define fprintf windows_fprintf +#endif + #ifndef MEMENTO_STACKTRACE_METHOD #ifdef __GNUC__ #define MEMENTO_STACKTRACE_METHOD 1 -- cgit v1.2.3