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.
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.