Where to add a CFLAG, such as -std=gnu99, into an (Eclipse CDT) autotools project

六月ゝ 毕业季﹏ 提交于 2019-12-31 13:55:24

问题


I have a simple Autotools C project (not C++), whose skeleton was created for me by Eclipse CDT (Juno).

CFLAGs (by inspection) seem to be -g -O2.

I want all of the generated make files to also have -std=gnu99 appended to the CFLAGs, because I use for (int i = 0; i < MAX; i++) and similar.

I can obviously hack the Makefile, but this gets overwritten on ./configure.

Where is the correct place to add (or change) CFLAGs which are required by the code (as opposed to those CFLAGs which the user might want to change)?

P.S. I'd like to do this by editing a text file (such as Makefile.am or configure.ac), rather than clicking a box in Eclipse, if possible.


回答1:


Just run into the same problem.

Here is the solution, just add the CFLAGS at the end of the configure options:

If you want to do this by editing configure.ac, just add CFLAGS="$CFLAGS something" into configure.ac




回答2:


If you mean to parameters for the compiler than see attached. (c++ build/setting/Misc

)


回答3:


In Eclipse Neon CDT, you also have a "Dialect" setting as shown below:



来源:https://stackoverflow.com/questions/11633763/where-to-add-a-cflag-such-as-std-gnu99-into-an-eclipse-cdt-autotools-projec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!