作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我想将 cppcheck 的输出重定向到一个文本文件。它向 stdout 打印大量信息,但如果我运行 cppcheck --enable=all --verbose 。 >/srv/samba/share/tmp/cppcheck.out
,我没有得到文件中的所有信息。为什么不?如何获取文件中的结果?
最佳答案
cppcheck的最新开发版本包含一个新选项:
--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)
您可以使用选项 --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)
关于linux - 如何将 cppcheck 的输出重定向到文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44420138/
我是一名优秀的程序员,十分优秀!