From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZUkm-0000Qv-CD for qemu-devel@nongnu.org; Mon, 25 Jan 2010 14:37:40 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZUkh-0000Nf-Ff for qemu-devel@nongnu.org; Mon, 25 Jan 2010 14:37:39 -0500 Received: from [199.232.76.173] (port=35928 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZUkh-0000Nb-Bi for qemu-devel@nongnu.org; Mon, 25 Jan 2010 14:37:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17532) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZUkg-0001eb-Mu for qemu-devel@nongnu.org; Mon, 25 Jan 2010 14:37:35 -0500 Date: Mon, 25 Jan 2010 21:34:26 +0200 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] Re: [PATCH] win32: use PRId64 instead of %lld Message-ID: <20100125193425.GG11998@redhat.com> References: <1264368221-3040-1-git-send-email-hpoussin@reactos.org> <20100125100905.GA9019@redhat.com> <4B5DD596.4040503@mail.berlios.de> <20100125174756.GB11998@redhat.com> <4B5DEFAA.5000601@mail.berlios.de> <20100125193205.GF11998@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100125193205.GF11998@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Herve Poussineau , qemu-devel@nongnu.org, lcapitulino@redhat.com On Mon, Jan 25, 2010 at 09:32:05PM +0200, Michael S. Tsirkin wrote: > On Mon, Jan 25, 2010 at 08:23:22PM +0100, Stefan Weil wrote: > > Michael S. Tsirkin schrieb: > > > On Mon, Jan 25, 2010 at 06:32:06PM +0100, Stefan Weil wrote: > > >> Michael S. Tsirkin schrieb: > > >>> On Sun, Jan 24, 2010 at 09:23:41PM +0000, Herve Poussineau wrote: > > >>>> Replace %lld occurrences by PRId64. > > >>> This is wrong. > > >>> long long values should be printed with %lld. > > >>> size_t - with %zd. PRId64 is for int64_t. > > >>> > > >> size_t => %zu, ssize_t => %zd might be better. > > >> > > >> And none of them works on win32, so using them > > >> there can result in a crash: > > >> > > >> size_t st = 4711; > > >> fprintf(stderr, "st=%zu, %s\n", st, "test"); > > >> > > >> printf functions on win32 don't know %z. > > >> They run > > >> > > >> fprintf(stderr, "st=zu, %s\n", st, "test"); > > >> > > >> which results in an memory access fault when printf > > >> wants to read the memory at address 0x4711. > > >> > > >> Regards, > > >> Stefan Weil > > > > > > Let's just implement a compliant printf? > > > > Or format the harddisk and install linux? > > Maybe that would be the better option :-) > > > > Of course you can add a printf to qemu, or to mingw32. > > No need to implement it - there are lots of good free > > implementations. > > > > The mingw developers are aware of the problem > > (http://www.mail-archive.com/mingw-w64-public@lists.sourceforge.net/msg00416.html). > > > > If there is an easy solution, they will fix the problem. > > > > I don't think the problem can be fixed easy: > > there is not only printf but a lot of functions which use > > format strings. They are implemented in msvcrt.dll. > > Replacing single functions in a dll is difficult. > > Telling code which printf in which dll is the correct > > one is difficult, too. > > > > There are easy solutions for QEMU: type cast > > size_t values to unsigned or uint32_t in printf > > or use a new macro (for example PRIsize) in > > format strings. That macro would be different for > > mingw32 and standard conforming systems. > > > The link above suggests adding > -D__USE_MINGW_ANSI_STDIO=1 > why don't we do just do this with mingw? Looking a bit lower, maybe just -std=c99. > People should also build with -Werror, then > it would be a build error not a crash. > > -- > MST