Say, if I compile the following using Visual Studio 2017 C++ compiler:
int r = 0;
wprintf_s(L"%s", r);
It will give me these very handy warnings:
warning C4477: 'wprintf' : format string '%s' requires an argument of type 'wchar_t *', but variadic argument 1 has type 'int'
warning C4313: 'wprintf': '%s' in format string conflicts with argument 1 of type 'int'
But when I try to define my own variadic function:
void MyFormat(_In_z_ _Printf_format_string_ LPCTSTR pszFormat, ...)
{
va_list argList;
va_start( argList, pszFormat );
//Do work ...
va_end( argList );
}
and then call it in a similar manner:
int r = 0;
MyFormat(L"%s", r);
It doesn't trigger them.
So I'm wondering if I can enable those warnings for my own variadic function?
sprintf
in this list, butsprintf2
not – RbMm