2017-06-07 11 views
2

Ich möchte die Ausgabe von cppcheck in eine Textdatei umleiten. Es druckt eine Menge Informationen zu stdout, aber wenn ich cppcheck --enable=all --verbose . > /srv/samba/share/tmp/cppcheck.out mache, bekomme ich nicht alle Informationen in der Datei, warum nicht?Wie kann ich die Ausgabe von cppcheck in Datei umleiten?

+3

Möglicherweise möchten Sie umleiten auch 'stderr', so versuchen Ersetzen Sie '>' durch '> &' –

Antwort

2

Die neueste Entwickler-Version von cppcheck enthält eine neue Option:

--output-file=<file name> 

diese Option Fügen Sie die Ausgabe in eine bestimmte Datei zu leiten.

Anwendungsbeispiel:

standardmäßig cppcheck druckt die Ergebnisse auf die Standardausgabe:

$ 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) 

Sie die Option --output-Datei verwenden können, wie das Ergebnis in report.txt speichern folgt:

$ cppcheck --enable=all --output-file=report.txt test.cpp 
Checking test.cpp ... 

Jetzt wird das Ergebnis in report.txt gespeichert:

$ 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) 

Als Alternative Sie die Ausgabe in eine Datei umleiten könnte:

$ cppcheck --enable=all test.cpp 2> report.txt 
Checking test.cpp ... 

nun das Ergebnis in report.txt gespeichert ist:

$ 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) 
Verwandte Themen