From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LScuK-0004pk-9y for qemu-devel@nongnu.org; Thu, 29 Jan 2009 14:50:36 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LScuJ-0004oX-93 for qemu-devel@nongnu.org; Thu, 29 Jan 2009 14:50:35 -0500 Received: from [199.232.76.173] (port=39266 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LScuI-0004oG-RG for qemu-devel@nongnu.org; Thu, 29 Jan 2009 14:50:34 -0500 Received: from mail-qy0-f20.google.com ([209.85.221.20]:39706) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LScuI-0007Ms-2K for qemu-devel@nongnu.org; Thu, 29 Jan 2009 14:50:34 -0500 Received: by qyk13 with SMTP id 13so178280qyk.10 for ; Thu, 29 Jan 2009 11:50:33 -0800 (PST) Message-ID: <49820879.5080209@codemonkey.ws> Date: Thu, 29 Jan 2009 13:50:17 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u" References: <1987955410-BeMail@laptop> <4981B0C9.8010403@codemonkey.ws> <20090129135523.GA7441@shareable.org> <4981C49E.5070207@codemonkey.ws> <20090129184234.GA13169@shareable.org> In-Reply-To: <20090129184234.GA13169@shareable.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 > ...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 > > >