When providing the wrong number of arguments to printf():
printf("%s", "foo", "bar");
or when by providing arguments of the wrong type:
printf("%d", "foo");
gcc is able to warn about these mistakes:
$ gcc -Wformat printf_too_many_arguments.c
printf_warnings.c: In function `main':
printf_warnings.c:5: warning: too many arguments for format
printf_warnings.c:5: warning: too many arguments for format
$ gcc -Wformat printf_argument_of_wrong_type.c
printf_warnings.c: In function `main':
printf_warnings.c:5: warning: format `%d' expects type `int', but argument 2 has type `char *'
printf_warnings.c:5: warning: format `%d' expects type `int', but argument 2 has type `char *'
How to get such warnings with Visual Studio 2005?
-- dave