From 7e7bdc19e76a5f87bccf7a84872f8d45295ee5b7 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Thu, 5 Aug 2021 20:10:07 +0100 Subject: Define PRIuSIZE to avoid issues compiling with msvcrt On windows and when cross compiling with mingw the standard library only supports C89 which means that print format arguments cannot take "%zu". To fix this, a PRIuSIZE macros is needed which expands to PRIu32 on windows 32 bit and PRIu64 on windows 64 bit. --- common.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'common.h') diff --git a/common.h b/common.h index d8a9622..a9386be 100644 --- a/common.h +++ b/common.h @@ -10,6 +10,18 @@ #define BITMASK(n) (UINTMAX_MAX >> (sizeof (uintmax_t) * CHAR_BIT - n)) +#ifndef PRIuSIZE + #ifdef _WIN32 + #ifdef _WIN64 + #define PRIuSIZE PRIu64 + #else + #define PRIuSIZE PRIu32 + #endif + #else + #define PRIuSIZE "zu" + #endif +#endif + enum endian { BIG, LITTLE }; size_t getsize(char c); -- cgit v1.2.3-54-g00ecf