qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Silence half of warnings in MinGW
@ 2009-01-28 19:43 Consul
  2009-01-28 21:50 ` Anthony Liguori
  0 siblings, 1 reply; 13+ messages in thread
From: Consul @ 2009-01-28 19:43 UTC (permalink / raw)
  To: qemu-devel

This patch suppresses a lot of mingw warnings like
qemu-img.c:288: warning: format '%I64u' expects type 'unsigned int', but 
argument 2 has type 'uint64_t'

signed-off-by: Alex Ivanov <void@aleksoft.net>

--- configure   (revision 6466)
+++ configure   (working copy)
@@ -573,6 +573,7 @@
  if test "$mingw32" = "yes" ; then
      linux="no"
      EXESUF=".exe"
+    CFLAGS+=" -Wno-format"
      oss="no"
      linux_user="no"
      bsd_user="no"

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH] Silence half of warnings in MinGW
  2009-01-28 19:43 [Qemu-devel] [PATCH] Silence half of warnings in MinGW Consul
@ 2009-01-28 21:50 ` Anthony Liguori
  2009-01-29  6:21   ` [Qemu-devel] Mingw GCC not recognising printf format "%I64u" Jamie Lokier
  0 siblings, 1 reply; 13+ messages in thread
From: Anthony Liguori @ 2009-01-28 21:50 UTC (permalink / raw)
  To: qemu-devel

Consul wrote:
> This patch suppresses a lot of mingw warnings like
> qemu-img.c:288: warning: format '%I64u' expects type 'unsigned int', 
> but argument 2 has type 'uint64_t'

I'd rather see the warning fixed (by switching to PRIu64) than to have 
the warnings disabled.

Regards,

Anthony Liguori

> signed-off-by: Alex Ivanov <void@aleksoft.net>
>
> --- configure   (revision 6466)
> +++ configure   (working copy)
> @@ -573,6 +573,7 @@
>  if test "$mingw32" = "yes" ; then
>      linux="no"
>      EXESUF=".exe"
> +    CFLAGS+=" -Wno-format"
>      oss="no"
>      linux_user="no"
>      bsd_user="no"
>
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Mingw GCC not recognising printf format "%I64u"
  2009-01-28 21:50 ` Anthony Liguori
@ 2009-01-29  6:21   ` Jamie Lokier
  2009-01-29  6:28     ` Jamie Lokier
  0 siblings, 1 reply; 13+ messages in thread
From: Jamie Lokier @ 2009-01-29  6:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: mingw-users

Anthony Liguori wrote:
> Consul wrote:
> >This patch suppresses a lot of mingw warnings like
> >qemu-img.c:288: warning: format '%I64u' expects type 'unsigned int', 
> >but argument 2 has type 'uint64_t'
> 
> I'd rather see the warning fixed (by switching to PRIu64) than to have 
> the warnings disabled.

Since that's in code for Windows, I'd rather see mingw's GCC fixed
to recognise %I64u, since that's fine Windows code.

Cc'd to mingw-users list for that reason.

-- Jamie

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u"
  2009-01-29  6:21   ` [Qemu-devel] Mingw GCC not recognising printf format "%I64u" Jamie Lokier
@ 2009-01-29  6:28     ` Jamie Lokier
  2009-01-29  7:42       ` François Revol
  0 siblings, 1 reply; 13+ messages in thread
From: Jamie Lokier @ 2009-01-29  6:28 UTC (permalink / raw)
  To: qemu-devel

Jamie Lokier wrote:
> Anthony Liguori wrote:
> > Consul wrote:
> > >This patch suppresses a lot of mingw warnings like
> > >qemu-img.c:288: warning: format '%I64u' expects type 'unsigned int', 
> > >but argument 2 has type 'uint64_t'
> > 
> > I'd rather see the warning fixed (by switching to PRIu64) than to have 
> > the warnings disabled.
> 
> Since that's in code for Windows, I'd rather see mingw's GCC fixed
> to recognise %I64u, since that's fine Windows code.
> 
> Cc'd to mingw-users list for that reason.

mingw-users is a closed list; it rejects the message.  Never mind.

-- Jamie

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u"
  2009-01-29  6:28     ` Jamie Lokier
@ 2009-01-29  7:42       ` François Revol
  2009-01-29 13:36         ` Anthony Liguori
  0 siblings, 1 reply; 13+ messages in thread
From: François Revol @ 2009-01-29  7:42 UTC (permalink / raw)
  To: qemu-devel

> Jamie Lokier wrote:
> > Anthony Liguori wrote:
> > > Consul wrote:
> > > >This patch suppresses a lot of mingw warnings like
> > > >qemu-img.c:288: warning: format '%I64u' expects type 'unsigned
> > > > int',
> > > >but argument 2 has type 'uint64_t'
> > >
> > > I'd rather see the warning fixed (by switching to PRIu64) than to
> > > have
> > > the warnings disabled.
> >
> > Since that's in code for Windows, I'd rather see mingw's GCC fixed
> > to recognise %I64u, since that's fine Windows code.

I suppose Windows doesn't #define the now standard PRI*N macros:
http://www.opengroup.org/onlinepubs/009695399/basedefs/inttypes.h.html

else you'd use PRIu64.

I won't blame it for not doing so, BeOS didn't have them either (but
hey, it was out before C99...).

François.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u"
  2009-01-29  7:42       ` François Revol
@ 2009-01-29 13:36         ` Anthony Liguori
  2009-01-29 13:55           ` Jamie Lokier
  0 siblings, 1 reply; 13+ messages in thread
From: Anthony Liguori @ 2009-01-29 13:36 UTC (permalink / raw)
  To: qemu-devel

François Revol wrote:
>> Jamie Lokier wrote:
>>     
>>> Anthony Liguori wrote:
>>>       
>>>> Consul wrote:
>>>>         
>>>>> This patch suppresses a lot of mingw warnings like
>>>>> qemu-img.c:288: warning: format '%I64u' expects type 'unsigned 
>>>>> int', 
>>>>> but argument 2 has type 'uint64_t'
>>>>>           
>>>> I'd rather see the warning fixed (by switching to PRIu64) than to 
>>>> have 
>>>> the warnings disabled.
>>>>         
>>> Since that's in code for Windows, I'd rather see mingw's GCC fixed
>>> to recognise %I64u, since that's fine Windows code.
>>>       
>
> I suppose Windows doesn't #define the now standard PRI*N macros:
> http://www.opengroup.org/onlinepubs/009695399/basedefs/inttypes.h.html
>
> else you'd use PRIu64.
>   

Or we can just do

#ifdef _WIN32
#define PRIu64 "%llu"
#endif

or whatever the correct format is.

Regards,

Anthony Liguori

> I won't blame it for not doing so, BeOS didn't have them either (but 
> hey, it was out before C99...).
>
> François.
>
>
>   

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u"
  2009-01-29 13:36         ` Anthony Liguori
@ 2009-01-29 13:55           ` Jamie Lokier
  2009-01-29 15:00             ` Anthony Liguori
  0 siblings, 1 reply; 13+ messages in thread
From: Jamie Lokier @ 2009-01-29 13:55 UTC (permalink / raw)
  To: qemu-devel

Anthony Liguori wrote:
> Or we can just do
> 
> #ifdef _WIN32
> #define PRIu64 "%llu"
> #endif
> 
> or whatever the correct format is.

Qemu does that already!

It's just it defines the macro to "%I64u" because that's the WIN32 way
of writing it...

A quick Google reveals that "%llu" actually doesn't work on Mingw.

(Though, if you were compiling on Cygwin (the Linux-like environment
for Windows), you must use "%llu".  But that also defines _WIN32... ho hum).

-- Jamie


> 
> Regards,
> 
> Anthony Liguori
> 
> >I won't blame it for not doing so, BeOS didn't have them either (but 
> >hey, it was out before C99...).
> >
> >François.
> >
> >
> >  
> 
> 
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u"
  2009-01-29 13:55           ` Jamie Lokier
@ 2009-01-29 15:00             ` Anthony Liguori
  2009-01-29 18:34               ` [Qemu-devel] " Consul
  2009-01-29 18:42               ` [Qemu-devel] " Jamie Lokier
  0 siblings, 2 replies; 13+ messages in thread
From: Anthony Liguori @ 2009-01-29 15:00 UTC (permalink / raw)
  To: qemu-devel

Jamie Lokier wrote:
> Anthony Liguori wrote:
>   
>> Or we can just do
>>
>> #ifdef _WIN32
>> #define PRIu64 "%llu"
>> #endif
>>
>> or whatever the correct format is.
>>     
>
> Qemu does that already!
>   

I don't think so.  mingw32 actuallt defines PRIu64 as "%I64u" even 
though GCC doesn't like it.  FWIW, the following seems to work for me:

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

Regards,

Anthony Liguori

> It's just it defines the macro to "%I64u" because that's the WIN32 way
> of writing it...
>   



> A quick Google reveals that "%llu" actually doesn't work on Mingw.
>
> (Though, if you were compiling on Cygwin (the Linux-like environment
> for Windows), you must use "%llu".  But that also defines _WIN32... ho hum).
>
> -- Jamie
>
>
>   
>> Regards,
>>
>> Anthony Liguori
>>
>>     
>>> I won't blame it for not doing so, BeOS didn't have them either (but 
>>> hey, it was out before C99...).
>>>
>>> François.
>>>
>>>
>>>  
>>>       
>>
>>     
>
>
>   

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: Mingw GCC not recognising printf format "%I64u"
  2009-01-29 15:00             ` Anthony Liguori
@ 2009-01-29 18:34               ` Consul
  2009-01-29 18:42               ` [Qemu-devel] " Jamie Lokier
  1 sibling, 0 replies; 13+ messages in thread
From: Consul @ 2009-01-29 18:34 UTC (permalink / raw)
  To: qemu-devel

Anthony Liguori wrote:
> 
> I don't think so.  mingw32 actuallt defines PRIu64 as "%I64u" even 
> though GCC doesn't like it.  FWIW, the following seems to work for me:
> 
> /* Mingw has a broken PRIu64 */
> #if defined(__MINGW32__)
> #undef PRIu64
> #define PRIu64 "Ld"
> #endif
> 

Ld truncates the output. It appears to be a GCC-4.3 problem, GCC-3.4.2 
is quite happy with I64u.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u"
  2009-01-29 15:00             ` Anthony Liguori
  2009-01-29 18:34               ` [Qemu-devel] " Consul
@ 2009-01-29 18:42               ` Jamie Lokier
  2009-01-29 19:50                 ` Anthony Liguori
  1 sibling, 1 reply; 13+ messages in thread
From: Jamie Lokier @ 2009-01-29 18:42 UTC (permalink / raw)
  To: qemu-devel

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.

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

-- Jamie

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Mingw GCC not recognising printf format "%I64u"
  2009-01-29 18:42               ` [Qemu-devel] " Jamie Lokier
@ 2009-01-29 19:50                 ` Anthony Liguori
  2009-01-29 20:44                   ` [Qemu-devel] " Consul
  0 siblings, 1 reply; 13+ messages in thread
From: Anthony Liguori @ 2009-01-29 19:50 UTC (permalink / raw)
  To: qemu-devel

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] Re: Mingw GCC not recognising printf format "%I64u"
  2009-01-29 19:50                 ` Anthony Liguori
@ 2009-01-29 20:44                   ` Consul
  2009-01-29 20:56                     ` Anthony Liguori
  0 siblings, 1 reply; 13+ messages in thread
From: Consul @ 2009-01-29 20:44 UTC (permalink / raw)
  To: qemu-devel

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

This bug should be fixed in GCC-4.4.0 (and backported to 3.4.2 MinGW's 
stable) However the latest version ported to MinGW  is still 4.3.0. Mind 
you I64u in the format line still gives the correct result, only this 
annoying warning is the problem. Other suggested format options silenced 
the warning, but also truncated the result :(

#include<stdio.h>
#include<inttypes.h>
//#define PRIu64 "I64u"
int main() {
     unsigned __int64 x = 1122334455667788LL;
     printf("Number: %"PRIu64"\n", x);
     return 0;
}

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] Re: Mingw GCC not recognising printf format "%I64u"
  2009-01-29 20:44                   ` [Qemu-devel] " Consul
@ 2009-01-29 20:56                     ` Anthony Liguori
  0 siblings, 0 replies; 13+ messages in thread
From: Anthony Liguori @ 2009-01-29 20:56 UTC (permalink / raw)
  To: qemu-devel

Consul wrote:
> Anthony Liguori wrote:
>> Okay, I wrote a small program that included inttypes.h.  PRIu64 was 
>> defined as I64u.
>
> This bug should be fixed in GCC-4.4.0 (and backported to 3.4.2 MinGW's 
> stable) However the latest version ported to MinGW  is still 4.3.0. 
> Mind you I64u in the format line still gives the correct result, only 
> this annoying warning is the problem. Other suggested format options 
> silenced the warning, but also truncated the result :(

Okay, then we can just ignore it for now.

Regards,

Anthony Liguori

> #include<stdio.h>
> #include<inttypes.h>
> //#define PRIu64 "I64u"
> int main() {
>     unsigned __int64 x = 1122334455667788LL;
>     printf("Number: %"PRIu64"\n", x);
>     return 0;
> }
>
>
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-01-29 20:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-28 19:43 [Qemu-devel] [PATCH] Silence half of warnings in MinGW Consul
2009-01-28 21:50 ` Anthony Liguori
2009-01-29  6:21   ` [Qemu-devel] Mingw GCC not recognising printf format "%I64u" Jamie Lokier
2009-01-29  6:28     ` Jamie Lokier
2009-01-29  7:42       ` François Revol
2009-01-29 13:36         ` Anthony Liguori
2009-01-29 13:55           ` Jamie Lokier
2009-01-29 15:00             ` Anthony Liguori
2009-01-29 18:34               ` [Qemu-devel] " Consul
2009-01-29 18:42               ` [Qemu-devel] " Jamie Lokier
2009-01-29 19:50                 ` Anthony Liguori
2009-01-29 20:44                   ` [Qemu-devel] " Consul
2009-01-29 20:56                     ` Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).