[cfe-dev] vprintf(3) and "format string is not a string literal"
Holger Schurig
hs4233 at mail.mn-solutions.de
Mon Dec 17 07:19:08 PST 2007
I'm not subscribed to clang mailing list, so not sure if my mail
comes throught. I'm reading the list via gmane.
I guess utilizing gcc __attribute__((format(...))) would help
here. You could put that at the log
int logmessage(
int loglevel,
char const *fmt __attribute__ (format (printf, 2, 3))),
...) {
// more code
}
That way the compiler knows that fmt *IS* a format string and
won't need to warn when it is used in vprintf().
Code that calls logmessage() would know that fmt is a printf-like
format string and can check calls to logmessage. This attribute
would even help in the case of call-backs.
BTW: why "char const *" and not "const char*" ?
More information about the cfe-dev
mailing list