|
From: Chris F. <cd...@fo...> - 2009-11-13 21:30:45
|
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. - Chris |