From f2252fdadc391f2a90bf0d15e1dde74921f98f60 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 23 Dec 2015 20:43:27 +0100 Subject: [PATCH] Introduce standard macros for format specifiers There exist standard macro definitions for the printf format specifiers. MS Visual Studio does not support that standard (at least not in older versions), so local definitions are needed there. Signed-off-by: Stefan Weil --- ccutil/host.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ccutil/host.h b/ccutil/host.h index 1845128e76..567f66ea97 100644 --- a/ccutil/host.h +++ b/ccutil/host.h @@ -68,7 +68,8 @@ #undef max #endif -#include // int32_t, ... +#include // PRId32, ... +#include // int32_t, ... /********************************************************/ /* __MAC__ */ @@ -111,8 +112,22 @@ typedef float FLOAT32; typedef double FLOAT64; typedef unsigned char BOOL8; -#define INT32FORMAT "%d" -#define INT64FORMAT "%lld" +#if defined(_WIN32) + +/* MinGW defines the standard PRI... macros, but MSVS doesn't. */ + +#if !defined(PRId32) +# define PRId32 "d" +#endif + +#if !defined(PRId64) +# define PRId64 "I64d" +#endif + +#endif /* _WIN32 */ + +#define INT32FORMAT "%" PRId32 +#define INT64FORMAT "%" PRId64 #define MAX_INT8 0x7f #define MAX_INT16 0x7fff