Mark the variadic *printf functions with __attribute__((format)).
svkampen opened this issue · 2 comments
The format
attribute marks a variadic function as taking a format string and corresponding arguments which should be type-checked against the format string. Marking printf_, sprintf_, etc. this way allows compilers to issue warnings when the supplied arguments do not have the correct type, as they would for the standard library functions.
The code change is very small, and currently implemented in svkampen@ba025a5 svkampen@d8aeaa9 (see comments below). I've guarded the __attribute__
declarations with #ifdef __GNUC__ ... #endif
, so that they don't interfere with compilers that don't support them.
The v*printf
-style functions can also be marked using
format(<archetype>, <string-index>, 0)
to check the format string itself for errors. See the same link.
Thanks, I must have glossed over that while reading the documentation... I've updated my branch - svkampen@d8aeaa9 now contains the attributes for all of the functions.