5544c1b
From 675a9bdcd5bf5bd663ee58cf5e4be4acf12d34ce Mon Sep 17 00:00:00 2001
5544c1b
From: Stefan Weil <sw@weilnetz.de>
5544c1b
Date: Wed, 22 Aug 2012 21:42:32 +0200
5544c1b
Subject: [PATCH] w32: Always use standard instead of native format strings
5544c1b
MIME-Version: 1.0
5544c1b
Content-Type: text/plain; charset=UTF-8
5544c1b
Content-Transfer-Encoding: 8bit
5544c1b
5544c1b
GLib 2.0 include files use __printf__ for the format attribute
5544c1b
which resolves to native format strings on w32 hosts.
5544c1b
5544c1b
QEMU wants standard format strings instead of native format
5544c1b
strings, so we simply change any declaration with __printf__
5544c1b
to use __gnu_printf__.
5544c1b
5544c1b
This works because all basic printf functions support both
5544c1b
kinds of format strings.
5544c1b
5544c1b
This fixes a compiler warning:
5544c1b
5544c1b
qapi/string-output-visitor.c: In function ‘print_type_int’:
5544c1b
qapi/string-output-visitor.c:34:5: warning: unknown conversion type character ‘l’ in format [-Wformat]
5544c1b
qapi/string-output-visitor.c:34:5: warning: too many arguments for format [-Wformat-extra-args]
5544c1b
5544c1b
Signed-off-by: Stefan Weil <sw@weilnetz.de>
5544c1b
Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
5544c1b
(cherry picked from commit 95df51a4a02a853af8828c281bce2d4f2a41d6fd)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1b
---
5544c1b
 compiler.h | 5 +++++
5544c1b
 1 file changed, 5 insertions(+)
5544c1b
5544c1b
diff --git a/compiler.h b/compiler.h
5544c1b
index 07ba1f8..c734a71 100644
5544c1b
--- a/compiler.h
5544c1b
+++ b/compiler.h
5544c1b
@@ -44,6 +44,11 @@
5544c1b
    /* Use gnu_printf when supported (qemu uses standard format strings). */
5544c1b
 #  define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
5544c1b
 #  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
5544c1b
+#  if defined(_WIN32)
5544c1b
+    /* Map __printf__ to __gnu_printf__ because we want standard format strings
5544c1b
+     * even when MinGW or GLib include files use __printf__. */
5544c1b
+#   define __printf__ __gnu_printf__
5544c1b
+#  endif
5544c1b
 # endif
5544c1b
 #if defined(_WIN32)
5544c1b
 #define GCC_WEAK __attribute__((weak))
5544c1b
-- 
5544c1b
1.7.12.1
5544c1b