[cfe-dev] clang missing a warning.

Tim Northover tnorthover at apple.com
Fri Jun 28 09:30:47 PDT 2013


> extern test_printf(const char *format, ...);

> It correctly warns about the lack of a third param in the "printf()" line.
> How do I get it to warn on the test_printf() line?

I think you want the “format” attribute. I couldn’t find Clang’s documentation (if it exists), but GCC’s is at http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html.

Basically, you add __attribute__((format(printf, 1, 2))).

Where ‘1’ means the format string is first argument, ‘2’ means start verifying it against arguments from 2 onwards.

Tim.




More information about the cfe-dev mailing list