[英]how can i redirect the output of cppcheck into file?
I would like to redirect the output of cppcheck to a text file. 我想将cppcheck的输出重定向到一个文本文件。 It prints a lot of information to
stdout
but if I do cppcheck --enable=all --verbose . > /srv/samba/share/tmp/cppcheck.out
它会向
stdout
打印很多信息,但是如果我执行cppcheck --enable=all --verbose . > /srv/samba/share/tmp/cppcheck.out
cppcheck --enable=all --verbose . > /srv/samba/share/tmp/cppcheck.out
, I do not get all the information in the file, why not? cppcheck --enable=all --verbose . > /srv/samba/share/tmp/cppcheck.out
,我没有获取文件中的所有信息,为什么不呢?
The latest dev version of cppcheck contains a new option: 最新的cppcheck开发版本包含一个新选项:
--output-file=<file name>
Add this option to direct the output into a specific file. 添加此选项可将输出定向到特定文件。
Usage example: 用法示例:
By default cppcheck prints its results to stdout: 默认情况下,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)
You can use the option --output-file as follows to store the result in report.txt: 您可以如下使用选项--output-file将结果存储在report.txt中:
$ cppcheck --enable=all --output-file=report.txt test.cpp
Checking test.cpp ...
Now the result is stored in report.txt: 现在,结果存储在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)
As an alternative you could redirect the output to a file: 或者,您可以将输出重定向到文件:
$ cppcheck --enable=all test.cpp 2> report.txt
Checking test.cpp ...
Now the result is stored in report.txt: 现在,结果存储在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.