From 757231cc6e777b8f4717d1467ef7efa01c7fde15 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Wed, 3 Jan 2018 17:41:16 +0000 Subject: Add the fmt library (#4065) * Replaces AppendVPrintf with fmt::sprintf * fmt::ArgList now used as a type safe alternative to varargs. * Removed SIZE_T_FMT compatibility macros. fmt::sprintf is fully portable and supports %zu. * Adds FLOG functions to log with fmt's native formatting style. --- Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp') diff --git a/Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp b/Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp index 0efaf9a59..31418b008 100644 --- a/Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp +++ b/Tools/GrownBiomeGenVisualiser/GrownBiomeGenVisualiser.cpp @@ -10,6 +10,7 @@ #define PROT_INT_BUFFER_SIZE (130 * 130) #include "Generating/ProtIntGen.h" +#include "fmt/printf.h" @@ -20,7 +21,6 @@ typedef int Color[3]; // Color is an array of 3 ints // Forward declarations, needed for GCC and Clang: -void log(const char * a_Fmt, ...) FORMATSTRING(1, 2); void outputBitmapFile( const AString & a_FileName, unsigned a_ImageSizeX, unsigned a_ImageSizeY, @@ -155,14 +155,12 @@ biomeColorMap[] = -void log(const char * a_Fmt, ...) +template +void log(const char * a_Fmt, const Args & ... a_Args) { - AString buf; - va_list args; - va_start(args, a_Fmt); - AppendVPrintf(buf, a_Fmt, args); - va_end(args); - std::cout << buf << std::endl << std::flush; + fmt::printf(a_Fmt, a_Args...); + putchar('\n'); + fflush(stdout); } -- cgit v1.2.3