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

我想将cppcheck的输出重定向到文本文件.它会向stdout输出大量信息但如果我执行cppcheck –enable = all –verbose. &GT /srv/samba/share/tmp/cppcheck.out,我没有得到文件中的所有信息,为什么不呢?

解决方法:

最新的开发版cppcheck包含一个新选项:

--output-file=

添加此选项可将输出定向到特定文件.

用法示例:

默认情况下,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)

标签:redirect,bash,linux,stdout,cppcheck

来源: https://codeday.me/bug/20190622/1264960.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值