qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] MinGW build


From: Peter Maydell
Subject: Re: [Qemu-devel] MinGW build
Date: Fri, 27 Nov 2015 18:49:21 +0000

On 28 November 2014 at 07:14, Stefan Weil <address@hidden> wrote:
> The libvixl code is correct, but the C++ compiler would need to be
> fixed. Here are some examples:
>
> disas/libvixl/a64/disasm-a64.cc:1340:57: warning: unknown conversion
> type character ā€˜lā€™ in format [-Wformat]
> disas/libvixl/a64/disasm-a64.cc:1340:57: warning: too many arguments for
> format [-Wformat-extra-args]
> disas/libvixl/a64/disasm-a64.cc:1492:42: warning: unknown conversion
> type character ā€˜lā€™ in format [-Wformat]
>
> That code uses PRIx64, so the format specifier is %llx which is correct.
> Obviously the C++ compiler ignores that QEMU uses ANSI format specifiers
> (compiler option -D__USE_MINGW_ANSI_STDIO=1) instead of the MS specific
> ones.

I finally got around to looking at this (a year later!), and it turns out
that the problem here is just that libvixl's code for marking functions
as having format strings doesn't have the check that we do in
include/qemu/compiler.h:

#if defined __GNUC__
# if !QEMU_GNUC_PREREQ(4, 4)
   /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
#  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
# else
   /* Use gnu_printf when supported (qemu uses standard format strings). */
#  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
#  if defined(_WIN32)
    /* Map __printf__ to __gnu_printf__ because we want standard format strings
     * even when MinGW or GLib include files use __printf__. */
#   define __printf__ __gnu_printf__
#  endif
# endif
#else
#define GCC_FMT_ATTR(n, m)
#endif

...which will effectively cause us to use 'gnu_printf' on this
compiler, which works. The libvixl headers always use plain 'printf',
which gets warnings. So I think we can fix this pretty simply in
disas/libvixl/utils.h by making it also do "use gnu_printf for
a compiler that's 4.4 or better".

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]