comparison 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
comparison
equal deleted inserted replaced
576:e4ae9ef86332 577:70d44ba005ac
35 #endif 35 #endif
36 36
37 37
38 #ifdef __cplusplus 38 #ifdef __cplusplus
39 extern "C" { 39 extern "C" {
40 #endif
41
42
43 // Kludge, as MinGW64 cross-compiler does not like certain
44 // printf(
45 #if defined(__MINGW64__)
46 # define TH_ATTR_PRINTF_FMT(xstart, xend)
47 #else
48 # define TH_ATTR_PRINTF_FMT(xstart, xend) __attribute__ ((__format__ (__printf__, (xstart), (xend))))
40 #endif 49 #endif
41 50
42 51
43 // Replacement for assert() 52 // Replacement for assert()
44 #ifdef HAVE_NO_ASSERT 53 #ifdef HAVE_NO_ASSERT
123 int th_get_error(); 132 int th_get_error();
124 int th_errno_to_error(int error); 133 int th_errno_to_error(int error);
125 const char *th_error_str(int error); 134 const char *th_error_str(int error);
126 135
127 void THERR(const char *fmt, ...) 136 void THERR(const char *fmt, ...)
128 __attribute__ ((__format__ (__printf__, 1, 2))); 137 TH_ATTR_PRINTF_FMT(1, 2);
129 void THMSG(int level, const char *fmt, ...) 138 void THMSG(int level, const char *fmt, ...)
130 __attribute__ ((__format__ (__printf__, 2, 3))); 139 TH_ATTR_PRINTF_FMT(2, 3);
131 void THPRINT(int level, const char *fmt, ...) 140 void THPRINT(int level, const char *fmt, ...)
132 __attribute__ ((__format__ (__printf__, 2, 3))); 141 TH_ATTR_PRINTF_FMT(2, 3);
133 142
134 void THERR_V(const char *fmt, va_list ap); 143 void THERR_V(const char *fmt, va_list ap);
135 void THMSG_V(int level, const char *fmt, va_list ap); 144 void THMSG_V(int level, const char *fmt, va_list ap);
136 void THPRINT_V(int level, const char *fmt, va_list ap); 145 void THPRINT_V(int level, const char *fmt, va_list ap);
137 146