-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Peter Rosin on 10/31/2008 9:19 AM: > main(void) > { > int32_t i = 32; > printf("%d", i); > return 0; > } > $ gcc -c -Wall int.c > int.c: In function `main': > int.c:6: warning: int format, int32_t arg (arg 2) > int.c:6: warning: int format, int32_t arg (arg 2) > > What should the format specifier be to not have that warning > on neither Cygwin nor Linux? (or anywhere for that matter)
http://www.opengroup.org/onlinepubs/009695399/basedefs/inttypes.h.html#tag_13_20 #include <inttypes.h> int32_t i; printf("%"PRId32"\n",i); > If the portable thing to do is casting all printf arguments, > I'm not sure the remedy is worth the damage. But all those > warnings are definitely an annoyance... Those warnings are issued for a reason - int is not guaranteed to be 32 bits. When using a 32-bit type, you should use the 32-bit type specifier in printf (PRId32, PRIo32, PRIu32, PRIx32, PRIX32) rather than a the int type specifier ("d", "o", "u", "x", "X"). Note that the PRI* macros are string constants, and that C and C++ string concatenation rules are in use here. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkkLJakACgkQ84KuGfSFAYAFBgCfR/KGvqcfIFuJkAYdmgdFzU/9 /kYAn08fkA5x8D4uv+Xrk7adHIU8Yn6S =Lx8a -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/