Mercurial > hg > th-libs
changeset 746:a557d1b2a356
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.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 21 Dec 2022 13:19:02 +0200 |
parents | 0c90dd46c49f |
children | 57ccf6402d2a |
files | th_types.h th_util.h |
diffstat | 2 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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