Je voudrais rediriger la sortie de cppcheck vers un fichier texte. Il imprime beaucoup d'informations à stdout
mais si je fais cppcheck --enable=all --verbose . > /srv/samba/share/tmp/cppcheck.out
, je ne reçois pas toutes les informations dans le fichier, pourquoi pas?comment puis-je rediriger la sortie de cppcheck dans le fichier?
2
A
Répondre
2
La dernière version dev de cppcheck contient une nouvelle option:
--output-file=<file name>
Ajouter cette option pour rediriger la sortie dans un fichier spécifique.
Exemple d'utilisation:
Par cppcheck par défaut imprime ses résultats à stdout:
$ cppcheck --enable=all test.cpp
Checking test.cpp ...
[test.cpp:54]: (style) The scope of the variable 'middle' can be reduced.
(information) Cppcheck cannot find all the include files (use --check-config for details)
Vous pouvez utiliser l'option --output fichier comme suit pour stocker le résultat dans report.txt:
$ cppcheck --enable=all --output-file=report.txt test.cpp
Checking test.cpp ...
maintenant, le résultat est stocké dans report.txt:
$ more report.txt
[test.cpp:54]: (style) The scope of the variable 'middle' can be reduced.
(information) Cppcheck cannot find all the include files (use --check-config for details)
Comme alternative, vous pouvez rediriger la sortie vers un fichier:
$ cppcheck --enable=all test.cpp 2> report.txt
Checking test.cpp ...
Maintenant, le résultat est stocké dans report.txt:
$ more report.txt
[test.cpp:54]: (style) The scope of the variable 'middle' can be reduced.
(information) Cppcheck cannot find all the include files (use --check-config for details)
Vous pouvez rediriger aussi 'stderr', alors essayez remplacer '>' par '> &' –