如何在gcc4.9中设置GCC_COLORS以发出着色诊断消息? [英] How to set GCC_COLORS in gcc4.9 to emit colorizing diagnostics messages?
问题描述
gcc4 .9支持编译器警告/错误消息的着色诊断。
我们可以使用选项 fdiagnostics-color
为特定程序启用它。目前我使用的是gcc4.9.1,我在makefile中添加了这个特殊的选项,如下所示:
pre code CC = / home / mantosh / gcc-4.9.1 / bin / g ++ -std = c ++ 1y -Wall -pthread
DFLAG = -g -gdwarf-2 -fdiagnostics-color = always
OUTFILE = test
$(OUTFILE):test.cpp
$(CC)$(DFLAG)-o $(OUTFILE)test.cpp
clean:
rm -f * .o $(OUTFILE)
如果我编译一个* .cpp文件, 。这是GCC添加的很棒的功能。
在阅读GCC官方链接时,似乎可以使用GCC环境变量 永久启用 em>GCC_COLORS 。
有人可以解释如何设置/更改/定制这个特定的环境变量吗?
我使用的是Ubuntu12.04 / GCC4.9.1。
只需将此行添加到〜/ .bashrc
文件中:
export GCC_COLORS ='error = 01; 31:warning = 01; 35:note = 01; 36:caret = 01; 32:locus = 01:quote = 01'
然后你可以用 source〜/ .bashrc
重新加载它,所以你不必注销/登录。
gcc4.9 supports the colorizing diagnostics for compiler warning/error messages.
We can enable it for a particular program using the option "fdiagnostics-color
". Currently I am using gcc4.9.1 and I append this particular option in my makefile as follows:
CC = /home/mantosh/gcc-4.9.1/bin/g++ -std=c++1y -Wall -pthread
DFLAG = -g -gdwarf-2 -fdiagnostics-color=always
OUTFILE = test
$(OUTFILE): test.cpp
$(CC) $(DFLAG) -o $(OUTFILE) test.cpp
clean:
rm -f *.o $(OUTFILE)
If I compile a *.cpp file a get the following nice coloured message. This is really great feature added by GCC.
While reading the GCC offical link, it seems that this setting can permanently enabled using the GCC environmental variable "GCC_COLORS".
Could somebody explains how to set/change/customize this particular environment variable?
I am using Ubuntu12.04/GCC4.9.1.
just add this line to your ~/.bashrc
file:
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
You can then reload it with source ~/.bashrc
so you don't have to logout/login.
这篇关于如何在gcc4.9中设置GCC_COLORS以发出着色诊断消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!