• Added support for checking arguments to a variadic function using the literal format string (printf, scanf, or scanf_s syntax).
vaformat(family, n, m)
Used for checking arguments to a variadic function using a literal format string. The family argument must be printf, scanf, or scanf_s, to specify that the format string contains specifiers for the printf, scanf, or scanf_s family of functions, respectively. The n argument specifies the number of the format string argument in the variadic function (1-127). The m argument specifies the number of the first argument to check (1-127). [6.00]
And an example:__declspec(vaformat(printf,2,3)) int __cdecl sprintf(char *buf, const char *format, ...);
What I’m trying to do is to make a compiler warn me about invalid arguments for debug macros. But
pocc -W2 -c test.c produces no warnings even for the following code. Am I doing something wrong? Is it broken in 7.00?
#include <stdio.h>
#include <stdarg.h>
__declspec(vaformat(printf,1,2)) void __cdecl foo(const char * fmt, ...)
{
va_list ap;
va_start(ap, fmt);
(void) vprintf(fmt, ap);
va_end(ap);
}
int main(void)
{
foo("%s %s %s", 1.0);
return 0;
}
Update: wow, it works for printf and others. And it works for mine function too, but only if there is a declaration without definition or if the declaration containing __declspec(varformat) is below the definition. I’m not sure if it is a bug, but… any reason for this?