diff th_util.h @ 577:70d44ba005ac

Define a helper macro for __attribute__ ((__format__ (__printf__, 2, 3))) TH_ATTR_PRINTF_FMT(2, 3) and use it, conditionally using a stub for MINGW64 to avoid "useless" warnings.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 09 Jan 2020 18:27:48 +0200
parents 7c0aa6bf484a
children 4d12924f9544
line wrap: on
line diff
--- a/th_util.h	Thu Jan 09 18:17:48 2020 +0200
+++ b/th_util.h	Thu Jan 09 18:27:48 2020 +0200
@@ -40,6 +40,15 @@
 #endif
 
 
+// Kludge, as MinGW64 cross-compiler does not like certain
+// printf(
+#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
@@ -125,11 +134,11 @@
 const char *th_error_str(int error);
 
 void    THERR(const char *fmt, ...)
-        __attribute__ ((__format__ (__printf__, 1, 2)));
+        TH_ATTR_PRINTF_FMT(1, 2);
 void    THMSG(int level, const char *fmt, ...)
-        __attribute__ ((__format__ (__printf__, 2, 3)));
+        TH_ATTR_PRINTF_FMT(2, 3);
 void    THPRINT(int level, const char *fmt, ...)
-        __attribute__ ((__format__ (__printf__, 2, 3)));
+        TH_ATTR_PRINTF_FMT(2, 3);
 
 void    THERR_V(const char *fmt, va_list ap);
 void    THMSG_V(int level, const char *fmt, va_list ap);