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

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

问题描述

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

I want to let my gcc always add some flags by default, is there a clean way to do this?

基本上,我每次调用 gcc 时都会传递一些标志,例如(但不限于)-g(以便它具有调试信息).

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. 别名g++=...,但我不喜欢这种做法;
  2. 写一个环绕g++的脚本,类似1;
  3. ...
  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.

推荐答案

运行strace gcc |grep specs 查看它在哪里搜索 specs 文件,然后去那里运行 gcc -dumpspecs >规格.您现在有一个可以编辑的规格文件.使用此参考:https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html

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天全站免登陆