[英]how can i redirect the output of cppcheck into file?
我想將cppcheck的輸出重定向到一個文本文件。 它會向stdout
打印很多信息,但是如果我執行cppcheck --enable=all --verbose . > /srv/samba/share/tmp/cppcheck.out
cppcheck --enable=all --verbose . > /srv/samba/share/tmp/cppcheck.out
,我沒有獲取文件中的所有信息,為什么不呢?
最新的cppcheck開發版本包含一個新選項:
--output-file=<file name>
添加此選項可將輸出定向到特定文件。
用法示例:
默認情況下,cppcheck將其結果打印到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)
您可以如下使用選項--output-file將結果存儲在report.txt中:
$ 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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.