默认添加一些标志给gcc(最好使用specs文件) [英] Add some flags by default to gcc (preferably using specs file)

查看:121
本文介绍了默认添加一些标志给gcc(最好使用specs文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的 gcc 默认添加一些标志,是否有干净的方式来做到这一点?



基本上我每次调用 gcc 时会传递一些标志,例如(但不限于) -g
    有几种解决方法,但它们很难看:


    1. alias g ++ = ... ,但我不喜欢这种方法; 写一个脚本包裹在g ++中,类似于1;
    2. ...

    只是修改规格文件,以便一切都是无缝的。

    解决方案

    运行 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:

    1. alias g++=..., but I don't like this approach;
    2. Write a script that wraps around the g++, similar to 1;
    3. ...

    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屋!

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