|
From: Daniel G. <go...@b1...> - 2009-11-15 12:01:38
|
On Friday 13 November 2009 10:30:03 pm Chris Frey wrote: > On Thu, Nov 12, 2009 at 04:36:40PM -0500, Chris Frey wrote: > > I think the GCC_FORMAT_CHECK is worth it in the long run (there were lots > > of printf style errors in the code), but the (void*) casts are > > unfortunate. Anyone know of a cleaner workaround? > > After a conversation on #gcc on irc.freenode.net (thanks to segher), > I had the following enlightenment: > > - the C standard does not guarantee that all pointers are the same > size on all platforms > > - for example, data pointers and function pointers can have > differing formats > > - the C standard guarantees that you can cast all pointers to void* > and back > > - the %p format string identifier only takes a void* > > - vararg functions cannot provide implicit casts, since there is > no prototype for the variable data > > - so in general, to be standard-C correct, you need to cast all > %p pointers to vararg functions > > - the -pedantic option makes all this show up explicitly, but in > most cases you don't need it, at least with gcc > > Basically there's no way around it, except disabling -pedantic in your > compiles, or adding (void*) casts to all %p pointers. > Thank you very much for sharing this knowledge! Best Regards, Daniel -- Daniel Gollub Geschaeftsfuehrer: Ralph Dehner FOSS Developer Unternehmenssitz: Vohburg B1 Systems GmbH Amtsgericht: Ingolstadt Mobil: +49-(0)-160 47 73 970 Handelsregister: HRB 3537 EMail: go...@b1... http://www.b1-systems.de Adresse: B1 Systems GmbH, Osterfeldstraße 7, 85088 Vohburg http://pgpkeys.pca.dfn.de/pks/lookup?op=get&search=0xED14B95C2F8CA78D |