In the following snippet the wrong usage of format specifiers inside the MyFormat() call should produce a warning, according to SAL specifications, and if I uncomment the identical call of printf(), I really will receive all these warnings, but my code is compiled silently even with /W4. What am I doing wrong? I'm using MSVC 2017 15.9.7 Community edition.
#include <stdio.h>
#include <stdarg.h>
void MyFormat(_Printf_format_string_ const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
vprintf(fmt, va);
va_end(va);
}
int main()
{
MyFormat("blabla %s\n", L"qq");
// printf("blabla %s\n", L"qq");
return 0;
}
Adding the /analyze
flag will cause this to produce a warning. However it is a different (and in my opinion inferior) warning than what you would get from printf
. Unfortunately I can't find a way to make a user-defined function to produce that style of warning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With