diff th_types.h @ 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 31bc1ed07cf5
children 57ccf6402d2a
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