Ok, I'm stuck... how to printf a Uint64 without getting warning messages?

This is going to be a big “Doh!” when I see the answer…

In testatomic.c I need to printf the value of Uint64 variable. Ok, no
problem, %llu should just work. And, in fact it does work. The value
comes out just fine.

BUT! I get the following warning everywhere I do that.

testatomic.c:85: warning: format ?%llu? expects type ?long long
unsigned int?, but argument 3 has type ?Uint64?
testatomic.c:88: warning: format ?%llu? expects type ?long long
unsigned int?, but argument 2 has type ?Uint64?
testatomic.c:91: warning: format ?%llu? expects type ?long long
unsigned int?, but argument 2 has type ?Uint64?

I’m using gcc --version == gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
I’m on an AMD x86_64 machine with and cat /proc/version == Linux
version 2.6.28-15-generic (buildd at yellow) (gcc version 4.3.3 (Ubuntu
4.3.3-5ubuntu4) ) #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009
I’m using the latest SDL 1.3 from svn.

I have also tried Lu and I get the same result.

I just hate having code generate such a long list of warnings.

And, yeah, since Uint64 is an SDL datatype this is an SDL related
problem. And, yeah, I have googled it and RTFMed and what I have
works, it just gives a nasty warning message and that is what I want
to get rid of.

Bob Pendleton–
±----------------------------------------------------------

It’s a pointless warning in this case. ‘long long unsigned int’ is
equivalent to ‘Uint64’ in terms of its storage capacity.

I suspect the rationale behind the warning is that someone might
typedef ‘sometype_t’ and then later change the size of it to be uint32
instead of uint64 or something, while leaving the printf()s to use
"%llu". It’s a “be careful what you’re doing here, you might screw it
up” warning.

I’m not sure what the proper way to silence the warning is, but the
compiler flag -Wno-format should shut it up.

  • StevenOn Mon, Sep 28, 2009 at 10:57 AM, Bob Pendleton wrote:

This is going to be a big “Doh!” when I see the answer…

In testatomic.c I need to printf the value of Uint64 variable. Ok, no
problem, %llu should just work. And, in fact it does work. The value
comes out just fine.

BUT! I get the following warning everywhere I do that.

testatomic.c:85: warning: format ?%llu? expects type ?long long
unsigned int?, but argument 3 has type ?Uint64?
testatomic.c:88: warning: format ?%llu? expects type ?long long
unsigned int?, but argument 2 has type ?Uint64?
testatomic.c:91: warning: format ?%llu? expects type ?long long
unsigned int?, but argument 2 has type ?Uint64?

I’m using gcc --version == gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
I’m on an AMD x86_64 machine with and cat /proc/version == Linux
version 2.6.28-15-generic (buildd at yellow) (gcc version 4.3.3 (Ubuntu
4.3.3-5ubuntu4) ) #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009
I’m using the latest SDL 1.3 from svn.

I have also tried Lu and I get the same result.

I just hate having code generate such a long list of warnings.

And, yeah, since Uint64 is an SDL datatype this is an SDL related
problem. And, yeah, I have googled it and RTFMed and what I have
works, it just gives a nasty warning message and that is what I want
to get rid of.

Bob Pendleton


±----------------------------------------------------------


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Maybe one of the printf macros in ‘inttypes.h’ will help?
http://www.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html

SAOn September 28, 2009, Bob Pendleton wrote:

This is going to be a big “Doh!” when I see the answer…

In testatomic.c I need to printf the value of Uint64 variable. Ok, no
problem, %llu should just work. And, in fact it does work. The value
comes out just fine.

You could always cast the parameter to: (long long unsigned int). That
should shut up the compiler.> ----- Original Message -----

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Steven Noonan
Sent: Monday, September 28, 2009 1:05 PM
To: SDL Development List
Subject: Re: [SDL] Ok,I’m stuck… how to printf a Uint64 without getting
warningmessages?

It’s a pointless warning in this case. ‘long long unsigned int’ is
equivalent to ‘Uint64’ in terms of its storage capacity.

I suspect the rationale behind the warning is that someone might typedef
’sometype_t’ and then later change the size of it to be uint32 instead of
uint64 or something, while leaving the printf()s to use “%llu”. It’s a “be
careful what you’re doing here, you might screw it up” warning.

I’m not sure what the proper way to silence the warning is, but the
compiler flag -Wno-format should shut it up.

  • Steven

On Mon, Sep 28, 2009 at 10:57 AM, Bob Pendleton wrote:

This is going to be a big “Doh!” when I see the answer…

In testatomic.c I need to printf the value of Uint64 variable. Ok, no
problem, %llu should just work. And, in fact it does work. The value
comes out just fine.

BUT! I get the following warning everywhere I do that.

testatomic.c:85: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 3 has type 'Uint64’
testatomic.c:88: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 2 has type 'Uint64’
testatomic.c:91: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 2 has type ‘Uint64’

I’m using gcc --version == gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3 I’m on an
AMD x86_64 machine with and cat /proc/version == Linux version
2.6.28-15-generic (buildd at yellow) (gcc version 4.3.3 (Ubuntu
4.3.3-5ubuntu4) ) #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009 I’m
using the latest SDL 1.3 from svn.

I have also tried Lu and I get the same result.

I just hate having code generate such a long list of warnings.

And, yeah, since Uint64 is an SDL datatype this is an SDL related
problem. And, yeah, I have googled it and RTFMed and what I have
works, it just gives a nasty warning message and that is what I want
to get rid of.

Bob Pendleton


±----------------------------------------------------------


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’m pretty sure ‘inttypes.h’ isn’t included with MSVC, so that’d screw
with cross-platform compatibility. But then again, I don’t think
"%llu" is supported by MSVC either (isn’t it “%I64” or something
idiotic like that?)

  • StevenOn Mon, Sep 28, 2009 at 11:05 AM, Stephen Anthony wrote:

On September 28, 2009, Bob Pendleton wrote:

This is going to be a big “Doh!” when I see the answer…

In testatomic.c I need to printf the value of Uint64 variable. Ok, no
problem, %llu should just work. And, in fact it does work. The value
comes out just fine.

Maybe one of the printf macros in ‘inttypes.h’ will help?
http://www.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html

you’re right about msvc not supporting %llu !

Steven Noonan a ?crit :> On Mon, Sep 28, 2009 at 11:05 AM, Stephen Anthony wrote:

On September 28, 2009, Bob Pendleton wrote:

This is going to be a big “Doh!” when I see the answer…

In testatomic.c I need to printf the value of Uint64 variable. Ok, no
problem, %llu should just work. And, in fact it does work. The value
comes out just fine.

Maybe one of the printf macros in ‘inttypes.h’ will help?
http://www.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html

I’m pretty sure ‘inttypes.h’ isn’t included with MSVC, so that’d screw
with cross-platform compatibility. But then again, I don’t think
"%llu" is supported by MSVC either (isn’t it “%I64” or something
idiotic like that?)

  • Steven

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You could always cast the parameter to: (long long unsigned int). ?That
should shut up the compiler.

Yep, that did it! I knew it would be “Doh!” moment when I saw the answer.

Anyway, I just checked it in.

Bob PendletonOn Mon, Sep 28, 2009 at 1:06 PM, Ken Rogoway wrote:

-----Original Message-----
From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Steven Noonan
Sent: Monday, September 28, 2009 1:05 PM
To: SDL Development List
Subject: Re: [SDL] Ok,I’m stuck… how to printf a Uint64 without getting
warningmessages?

It’s a pointless warning in this case. ‘long long unsigned int’ is
equivalent to ‘Uint64’ in terms of its storage capacity.

I suspect the rationale behind the warning is that someone might typedef
’sometype_t’ and then later change the size of it to be uint32 instead of
uint64 or something, while leaving the printf()s to use “%llu”. It’s a “be
careful what you’re doing here, you might screw it up” warning.

I’m not sure what the proper way to silence the warning is, but the
compiler flag -Wno-format should shut it up.

  • Steven

On Mon, Sep 28, 2009 at 10:57 AM, Bob Pendleton <@Bob_Pendleton> wrote:

This is going to be a big “Doh!” when I see the answer…

In testatomic.c I need to printf the value of Uint64 variable. Ok, no
problem, %llu should just work. And, in fact it does work. The value
comes out just fine.

BUT! I get the following warning everywhere I do that.

testatomic.c:85: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 3 has type 'Uint64’
testatomic.c:88: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 2 has type 'Uint64’
testatomic.c:91: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 2 has type ‘Uint64’

I’m using gcc --version == gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3 I’m on an
AMD x86_64 machine with and cat /proc/version == Linux version
2.6.28-15-generic (buildd at yellow) (gcc version 4.3.3 (Ubuntu
4.3.3-5ubuntu4) ) #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009 I’m
using the latest SDL 1.3 from svn.

I have also tried Lu and I get the same result.

I just hate having code generate such a long list of warnings.

And, yeah, since Uint64 is an SDL datatype this is an SDL related
problem. And, yeah, I have googled it and RTFMed and what I have
works, it just gives a nasty warning message and that is what I want
to get rid of.

Bob Pendleton


±----------------------------------------------------------


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


±----------------------------------------------------------

This is going to be a big “Doh!” when I see the answer…

In testatomic.c I need to printf the value of Uint64 variable. Ok, no
problem, %llu should just work. And, in fact it does work. The value
comes out just fine.

Maybe one of the printf macros in ‘inttypes.h’ will help?
http://www.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html

I’m pretty sure ‘inttypes.h’ isn’t included with MSVC, so that’d screw
with cross-platform compatibility. But then again, I don’t think
"%llu" is supported by MSVC either (isn’t it “%I64” or something
idiotic like that?)

Great, now everyone using MSVC is going to get error messages. Anyone
want to fix it for VC?

Bob PendletonOn Mon, Sep 28, 2009 at 1:08 PM, Steven Noonan wrote:

On Mon, Sep 28, 2009 at 11:05 AM, Stephen Anthony wrote:

On September 28, 2009, Bob Pendleton wrote:

  • Steven

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


±----------------------------------------------------------

Yeah, I went ahead and checked in a version that uses cross-platform macros.On Mon, Sep 28, 2009 at 11:46 AM, Bob Pendleton wrote:

On Mon, Sep 28, 2009 at 1:06 PM, Ken Rogoway wrote:

You could always cast the parameter to: (long long unsigned int). ?That
should shut up the compiler.

Yep, that did it! I knew it would be “Doh!” moment when I saw the answer.

Anyway, I just checked it in.

Bob Pendleton

-----Original Message-----
From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Steven Noonan
Sent: Monday, September 28, 2009 1:05 PM
To: SDL Development List
Subject: Re: [SDL] Ok,I’m stuck… how to printf a Uint64 without getting
warningmessages?

It’s a pointless warning in this case. ‘long long unsigned int’ is
equivalent to ‘Uint64’ in terms of its storage capacity.

I suspect the rationale behind the warning is that someone might typedef
’sometype_t’ and then later change the size of it to be uint32 instead of
uint64 or something, while leaving the printf()s to use “%llu”. It’s a “be
careful what you’re doing here, you might screw it up” warning.

I’m not sure what the proper way to silence the warning is, but the
compiler flag -Wno-format should shut it up.

  • Steven

On Mon, Sep 28, 2009 at 10:57 AM, Bob Pendleton wrote:

This is going to be a big “Doh!” when I see the answer…

In testatomic.c I need to printf the value of Uint64 variable. Ok, no
problem, %llu should just work. And, in fact it does work. The value
comes out just fine.

BUT! I get the following warning everywhere I do that.

testatomic.c:85: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 3 has type 'Uint64’
testatomic.c:88: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 2 has type 'Uint64’
testatomic.c:91: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 2 has type ‘Uint64’

I’m using gcc --version == gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3 I’m on an
AMD x86_64 machine with and cat /proc/version == Linux version
2.6.28-15-generic (buildd at yellow) (gcc version 4.3.3 (Ubuntu
4.3.3-5ubuntu4) ) #49-Ubuntu SMP Tue Aug 18 19:25:34 UTC 2009 I’m
using the latest SDL 1.3 from svn.

I have also tried Lu and I get the same result.

I just hate having code generate such a long list of warnings.

And, yeah, since Uint64 is an SDL datatype this is an SDL related
problem. And, yeah, I have googled it and RTFMed and what I have
works, it just gives a nasty warning message and that is what I want
to get rid of.

Bob Pendleton


±----------------------------------------------------------


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


±----------------------------------------------------------


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC