10

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.

3 Answers 3

5

Just run into the same problem.

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

enter image description here

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

1
  • If added CFLAGS="-std=gnu99" and enabled CFLAGS check boxes like Debg(-g), Gprof support(-pg) then only CFLAGS="-std=gnu99"** is took as effective, ignoring other GUI enabled CFLAGS Nov 14, 2017 at 8:31
1

If you mean to parameters for the compiler than see attached. (c++ build/setting/Miscenter image description here)

4
  • On my machine, I have only the Binary Parsers and Error Parsers tabs. I also have an additional, greyed-out Configuration: 'Build (GNU) [ Active ]' drop down list, above those tabs. I downloaded "Eclipse IDE for C/C++ Developers, 143 MB" from eclipse.org/downloads a week ago.
    – fadedbee
    Jul 25, 2012 at 9:39
  • I also created a brand-new project, and it still only has two tabs.
    – fadedbee
    Jul 25, 2012 at 9:55
  • 2
    I just created a non-autotools project and it has all five tabs. I think your answer only applies to non-autotools projects, which is not the question.
    – fadedbee
    Jul 25, 2012 at 10:11
  • This was useful for my cross-compiler c project.
    – Larry
    Mar 14, 2017 at 0:08
0

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

enter image description here

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.