From a4c745bd8fc7018c9e6e47fc2a6a909e51deea3b Mon Sep 17 00:00:00 2001 From: "John Chen (CLR)" Date: Sun, 14 Feb 2016 14:25:32 -0800 Subject: [PATCH] Fix fprintf in crossgen CrossGen configures its stdout to allow only Unicode output functions. Add a wrapper to fprintf to allow it to work inside crossgen. --- src/jit/host.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/jit/host.h b/src/jit/host.h index ea12c87..cf20713 100644 --- a/src/jit/host.h +++ b/src/jit/host.h @@ -33,6 +33,20 @@ void gcDump_logf(const char* fmt, ...); void logf(unsigned level, const char* fmt, ...); +#if defined(CROSSGEN_COMPILE) && !defined(PLATFORM_UNIX) && !defined(fprintf) +// On Windows, CrossGen configures its stdout to allow Unicode output only. +// The following wrapper allows fprintf to work with stdout. +inline int fprintfCrossgen(FILE *stream, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + int ret = stream == stdout ? logf_stdout(fmt, args) : vfprintf(stream, fmt, args); + va_end(args); + return ret; +} +#define fprintf fprintfCrossgen +#endif + extern "C" void __cdecl assertAbort(const char *why, const char *file, unsigned line); -- 2.7.4