如何保存gcc的错误输出到文件 [英] How to save the error output of gcc to file

查看:160
本文介绍了如何保存gcc的错误输出到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我编译我的代码,我得到一堆错误,我跨越屏幕,我可以看到错误开始在哪里。如何将gcc的输出保存到文件?

When I compile my code I get a bunch of errors which I span through the screen and I can see where does the error start. How can I save the output of gcc to a file?

我尝试了像


gcc> log.txt

gcc > log.txt

或者greping结果,但它没有工作。搜索google产量主要是解释如何使用c ++打印到文件

or grepping the result but it didn't work. Searching google yields mostly result on explaining how to print to file with c++

推荐答案

GCC输出错误到标准错误流不发送到标准输出流。您需要重定向标准错误,而不是标准输出。在bash中:

GCC outputs errors to the standard error stream not to the standard output stream. You need to redirect standard error, instead of standard output. In bash:

gcc 2> log.txt

这篇关于如何保存gcc的错误输出到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆