微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linux – 如何将cppcheck的输出重定向到文件中?

我想将cppcheck的输出重定向到文本文件.它会向stdout输出大量信息但如果我执行cppcheck –enable = all –verbose. &GT /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.
  (@R_511_4045@ion) 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.
(@R_511_4045@ion) 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.
(@R_511_4045@ion) Cppcheck cannot find all the include files (use --check-config for details)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐