# HG changeset patch # User Matti Hamalainen # Date 1671621542 -7200 # Node ID a557d1b2a35627a0b48cfcd1c86c0e90f4408ca8 # Parent 0c90dd46c49f8d78bb3190db1248719b3bc9fea2 Move TH_ATTR_PRINTF_FMT macro definition to th_types.h and improve the preprocessor checks. Apparently newer versions (not sure since which version exactly) seem to work fine with the attribute defined. Enabling for MinGW GCC >= 12 for now, though it may have worked earlier. diff -r 0c90dd46c49f -r a557d1b2a356 th_types.h --- a/th_types.h Wed Dec 21 13:17:20 2022 +0200 +++ b/th_types.h Wed Dec 21 13:19:02 2022 +0200 @@ -21,6 +21,16 @@ #endif +// Older MinGW-w64 versions do not play well with certain PRI* and type +// checking of printf() format specifiers, so .. only define the attribute +// macro for GCC/clang and new enough MinGW-w64. +#if (defined(__GNUC__) || defined(__clang__)) && (!defined(__MINGW64__) || __GNUC__ >= 12) +# define TH_ATTR_PRINTF_FMT(xstart, xend) __attribute__ ((__format__ (__printf__, (xstart), (xend)))) +#else +# define TH_ATTR_PRINTF_FMT(xstart, xend) +#endif + + // Check for system type #if defined(__WIN64) || defined(_WIN64) || defined(__WIN32) || defined(_WIN32) # define TH_PLAT_WINDOWS 1 diff -r 0c90dd46c49f -r a557d1b2a356 th_util.h --- a/th_util.h Wed Dec 21 13:17:20 2022 +0200 +++ b/th_util.h Wed Dec 21 13:19:02 2022 +0200 @@ -39,14 +39,6 @@ #endif -// Kludge, as MinGW64 cross-compiler does not like certain printf() format specifiers -#if defined(__MINGW64__) -# define TH_ATTR_PRINTF_FMT(xstart, xend) -#else -# define TH_ATTR_PRINTF_FMT(xstart, xend) __attribute__ ((__format__ (__printf__, (xstart), (xend)))) -#endif - - // Replacement for assert() #ifdef HAVE_NO_ASSERT # ifdef NDEBUG