/*--- log.c -----------------------------------------------------------------*/
+#if defined(G_OS_WIN32) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+/*
+ * On MinGW, we need to specify the gnu_printf format flavor or GCC
+ * will assume non-standard Microsoft printf syntax.
+ */
+SR_PRIV int sr_log(int loglevel, const char *format, ...)
+ __attribute__((__format__ (__gnu_printf__, 2, 3)));
+#else
SR_PRIV int sr_log(int loglevel, const char *format, ...) G_GNUC_PRINTF(2, 3);
+#endif
/* Message logging helpers with subsystem-specific prefix string. */
#define sr_spew(...) sr_log(SR_LOG_SPEW, LOG_PREFIX ": " __VA_ARGS__)
#include <stdarg.h>
#include <stdio.h>
+#include <glib/gprintf.h>
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
seconds = rest_us / G_TIME_SPAN_SECOND;
microseconds = rest_us % G_TIME_SPAN_SECOND;
- ret = fprintf(stderr, "sr: [%.2" PRIu64 ":%.2u.%.6u] ",
+ ret = g_fprintf(stderr, "sr: [%.2" PRIu64 ":%.2u.%.6u] ",
minutes, seconds, microseconds);
} else {
ret = fputs("sr: ", stderr);
}
- if (ret < 0 || vfprintf(stderr, format, args) < 0
+ if (ret < 0 || g_vfprintf(stderr, format, args) < 0
|| putc('\n', stderr) < 0)
return SR_ERR;