默认添加一些标志给gcc(最好使用specs文件) [英] Add some flags by default to gcc (preferably using specs file)
问题描述
我想让我的 gcc
默认添加一些标志,是否有干净的方式来做到这一点?
基本上我每次调用
gcc
时会传递一些标志,例如(但不限于) -g $ c $ 有几种解决方法,但它们很难看:
-
alias g ++ = ...
,但我不喜欢这种方法; 写一个脚本包裹在g ++中,类似于1;
- ...
只是修改规格文件,以便一切都是无缝的。
解决方案运行 strace gcc | grep specs
来查看它在哪里搜索规格文件,然后去那里运行 gcc -dumpspecs>功能
。您现在有一个可供编辑的规格文件。使用此参考: https://gcc.gnu.org/onlinedocs/gcc/ Spec-Files.html
I want to let my gcc
always add some flags by default, is there a clean way to do this?
Basically I have some flags I pass every time I invoke gcc
, for example (but not limited to) -g
(so that it has debug information).
There are several workarounds but they are ugly:
alias g++=...
, but I don't like this approach;
- Write a script that wraps around the g++, similar to 1;
- ...
I would prefer just modifying the specs file so that everything is seamless.
解决方案 Run strace gcc | grep specs
to see where it is searching for the specs file, then go there and run gcc -dumpspecs > specs
. You now have a specs file ready for editing. Use this reference: https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html
这篇关于默认添加一些标志给gcc(最好使用specs文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!