问题描述
g++ 有时会产生相当复杂的输出.特别是在处理模板时.是否有任何工具可以使 g++ 输出更具可读性?...至少有一些颜色?
g++ sometimes produces pretty convoluted outputs. Specially when dealing with templates. Is there any tool that makes g++ output more readable? ... at least some color?
在这里问这个问题可能听起来很傻,但我无法通过谷歌搜索.
It may sound silly to ask this question here, but I've been unable to google my way out of this.
推荐答案
如果你可以随意切换编译器,试试 clang++.它的错误输出大部分时间都非常清楚,有时它甚至会告诉您如何修复错误.您可以在此处找到 gcc 与 clang 错误输出的比较:http://clang.llvm.org/diagnostics.html.
If you're free to switch compiler, try clang++. It's error outputs are most of the time very clear and sometimes it will even tell you what to do to fix your error. You can find a comparison of gcc vs clang error output here: http://clang.llvm.org/diagnostics.html.
否则,如 Matteo Italia 所述,请查看 STLFilt.
Otherwise, as noted by Matteo Italia, look to STLFilt.
对于颜色方面,Edwin Buck 的解决方案(colorgcc)非常好.您可以为其创建名为 gcc、g++ 等的符号链接,以便在您运行编译器命令时始终使用它(前提是您正确设置了 colorgcc 脚本中的路径).从 Makefile 编译一些大型项目时,我发现这特别方便.极大地帮助检测到底哪里出了问题(尤其是当您使用 make -j
进行并行编译时).
For the color aspect, Edwin Buck's solution (colorgcc) is very good. You can create symlinks to it named gcc, g++, etc so that it always gets used whenever you run a compiler command (provided you setup the paths in the colorgcc script correctly). I find this especially convenient when compiling some large project from a Makefile. Helps tremendously to detect where exactly something went wrong (especially when you do parallel compilations with make -j
).
这篇关于改善 g++ 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!