From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LSbqb-0006Aq-Me for qemu-devel@nongnu.org; Thu, 29 Jan 2009 13:42:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LSbqZ-00069p-Qn for qemu-devel@nongnu.org; Thu, 29 Jan 2009 13:42:41 -0500 Received: from [199.232.76.173] (port=57092 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LSbqZ-00069k-KC for qemu-devel@nongnu.org; Thu, 29 Jan 2009 13:42:39 -0500 Received: from mail2.shareable.org ([80.68.89.115]:44932) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LSbqY-0000oz-UB for qemu-devel@nongnu.org; Thu, 29 Jan 2009 13:42:39 -0500 Received: from jamie by mail2.shareable.org with local (Exim 4.63) (envelope-from ) id 1LSbqU-0003TX-Ev for qemu-devel@nongnu.org; Thu, 29 Jan 2009 18:42:34 +0000 Date: Thu, 29 Jan 2009 18:42:34 +0000 From: Jamie Lokier Subject: Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u" Message-ID: <20090129184234.GA13169@shareable.org> References: <1987955410-BeMail@laptop> <4981B0C9.8010403@codemonkey.ws> <20090129135523.GA7441@shareable.org> <4981C49E.5070207@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4981C49E.5070207@codemonkey.ws> 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 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. > 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. The same _could_ happen with "%Ld" or "%Lu", if Microsoft hasn't implemented that as 64-bit. -- Jamie