qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u"


From: Anthony Liguori
Subject: Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u"
Date: Thu, 29 Jan 2009 13:50:17 -0600
User-agent: Thunderbird 2.0.0.19 (X11/20090105)

Jamie Lokier wrote:
Anthony Liguori wrote:
#ifdef _WIN32
#define PRIu64 "%llu"
#endif

Qemu does that already!
I don't think so. mingw32 actuallt defines PRIu64 as "%I64u" even though GCC doesn't like it.

Look again.  qemu/qemu-common.h:

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define WINVER 0x0501  /* needed for ipv6 bits */
#include <windows.h>
...etc...
#define PRId64 "I64d"
#define PRIx64 "I64x"
#define PRIu64 "I64u"
#define PRIo64 "I64o"
#endif

The only condition is whether _WIN32 is defined, which means WIN32
API, except that it's also defined with Cygwin (and other unix
emulations) which have quite different functions.

Okay, I wrote a small program that included inttypes.h. PRIu64 was defined as I64u.

FWIW, the following seems to work for me:

/* Mingw has a broken PRIu64 */
#if defined(__MINGW32__)
#undef PRIu64
#define PRIu64 "Ld"
#endif

(Should by "Lu", btw).

How you checked it prints correctly?  There are Googlable reports of
people using "%lld" on Mingw saying that it doesn't print large 64-bit
values correctly, because it truncates them to 32 bits, and trying
"%I64u" and it works.  Possibly due to Mingw programs calling
Microsoft's C library, therefore being subject to Windowsness.

I only tried with a small number so it could possibly truncate large numbers.

Regards,

Anthony Liguori

The same _could_ happen with "%Ld" or "%Lu", if Microsoft hasn't
implemented that as 64-bit.

-- Jamie







reply via email to

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