En fournissant le nombre incorrect d'arguments à printf():Comment obtenir des avertissements printf dans Visual Studio 2005?
printf("%s", "foo", "bar");
ou quand en fournissant des arguments du mauvais type:
printf("%d", "foo");
gcc est en mesure de mettre en garde contre ces erreurs:
$ 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 *'
Comment obtenir de tels avertissements avec Visual Studio 2005?
- dave
Le compilateur gcc contient un code spécial qui "connaît" la fonction printf et la chaîne de format. pour autant que je sache, le compilateur MS n'a pas cela. –