From d15ab96a51287469082e8d9068e2608a386f9e5f Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 17 Mar 2016 21:55:12 +0000 Subject: Fix size_t printf formatting The printf formatting for size_t is set in c99 as %zu but in windows it is %Iu this is solved by adding and inttypes style PRI macro for size_t This also uses this macro everywhere size_t is formatted. --- utils/utils.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'utils/utils.h') diff --git a/utils/utils.h b/utils/utils.h index e4688ce2c..4b5360c5c 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -77,12 +77,22 @@ struct dirent; #define PRId64 "lld" #endif -/* Windows does not have POSIX formating codes or mkdir so work around that */ +/* Windows does not have sizet formating codes or POSIX mkdir so work + * around that + */ #if defined(_WIN32) -#define SSIZET_FMT "Iu" +/** windows printf formatting for size_t type */ +#define PRIsizet "Iu" +/** windows printf formatting for ssize_t type */ +#define PRIssizet "Id" +/** windows mkdir function */ #define nsmkdir(dir, mode) mkdir((dir)) #else -#define SSIZET_FMT "zd" +/** c99 standard printf formatting for size_t type */ +#define PRIsizet "zu" +/** c99 standard printf formatting for ssize_t type */ +#define PRIssizet "zd" +/** POSIX mkdir function */ #define nsmkdir(dir, mode) mkdir((dir), (mode)) #endif -- cgit v1.2.1