printf() checking for custom functions
Randall Hopper
viznut@charter.net
Wed Sep 26 08:35:00 GMT 2007
David Daney:
|Randall Hopper wrote:
|>-Wformat causes printf() args to be checked based on the format:
|>How do ask gcc to apply this same checking to user-defined functions?
|>
|> int myDebug(const char *format, ...);
|
|Look at:
|
|http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attributes
That's perfect. Thanks. A problem I hit with it though is that:
myDebug( "" );
fails to compile with:
clone.cxx:252: warning: zero-length printf format string
Naturally, I compile with -Werror. I tried -Wno-format-zero-length,
however this is C++ code, and GCC fails the build with:
cc1plus: warning: command line option "-Wno-format-zero-length" is valid
for C/ObjC but not for C++
even though I'm specifying valid printf() arguments.
Any way to kill this warning in C++?
Randall
P.S. myDebug() adds its own linefeed internally, so using "\n" instead
of "" isn't correct here.
More information about the Gcc-help
mailing list