2017-06-07 56 views
2

私は、cppcheckの出力をテキストファイルにリダイレクトしたいと思います。 stdoutに多くの情報を出力しますが、cppcheck --enable=all --verbose . > /srv/samba/share/tmp/cppcheck.outを実行すると、ファイル内のすべての情報が得られません。どうしてですか?どうすればcppcheckの出力をファイルにリダイレクトできますか?

+3

ます。また 'stderr'をリダイレクトしたい、そうしようとします'>'を '>&'で置き換える –

答えて

2

cppcheckの最新のdevのバージョンが新しいオプションが含まれています

--output-file=<file name> 

は、特定のファイルへの出力を指示するには、このオプションを追加します。

使用例:デフォルトのcppcheckによって

は、標準出力にその結果を出力します。

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

次のようにあなたがREPORT.TXTに結果を格納するために--output-ファイルオプションを使用することができます。

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

さて結果は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) 
出力をファイルにリダイレクトすることができ、代替として

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

さて結果は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) 
関連する問題