默认标志在Eclipse中gcc编译器 [英] Default flags for gcc compiler in Eclipse

查看:261
本文介绍了默认标志在Eclipse中gcc编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我所有的C程序的选项 -Wall -pedantic -ansi 默认情况下进行编译。有没有办法使Eclipse默认情况下,所有项目的这些标志添加到编译器命令?

I want all my C programs to be compiled with the options -Wall -pedantic -ansi by default. Is there a way to have Eclipse add these flags to the compiler command by default for all projects?

推荐答案

分配CFLAGS包括那些价值观,并有Eclipse中运行,在默认情况汇编(如make)。

Assign CFLAGS to include those values, and have Eclipse run a tool that uses that environment variable by default when compiling (such as make).

您可能需要运行Eclipse(然后当Eclipse遇到让他们得到继承)之前指定的环境变量,但有可能是指定在Eclipse默认环境的一种方式。

You may have to specify environment variables before running Eclipse (and then they get inherited when Eclipse runs make) but there might be a way to specify default environment in Eclipse.

(我不使用Eclipse,因此我不得不看到有关安装和测试此。如果是的话也许这个答案可以慢跑别人的记忆,随意编辑)

(I don't use Eclipse, so I'll have to see about installing and testing this; or maybe this answer can jog someone's memory, if so, feel free to edit.)

顺便说一句,你可能想-std = C99,而不是-ansi。 -ansi选项只是意味着-std = C89或-std = C ++ 98,这取决于你正在编译C或C ++,以及两者的这些标准都出现了他们的年龄。

As an aside, you might want -std=c99 instead of -ansi. The -ansi option simply means -std=c89 or -std=c++98, depending on whether you're compiling C or C++, and both of those standards are showing their age.

我Eclipse安装一个虚拟机内运行Windows,以测试这一点,即使是CFLAGS环境中,Eclipse不使用它。 Eclipse还pretends(由像显示文本让所有和使清洁),它的运行使少数情况/项目,我试过了,当没有真正使用make(可能使用一些内部引擎)它。这个答案是错误的轨道上的Eclipse。

I installed Eclipse inside a VM running Windows to test this, and, even though CFLAGS is in the environment, Eclipse doesn't use it. Eclipse also pretends (by displaying text like "make all" and "make clean") that it's running make in a few situations/projects I tried, when it is not really using make (probably using some internal engine). This answer was on the wrong track for Eclipse.

这篇关于默认标志在Eclipse中gcc编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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