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.

fadedbee
  • 42,671
  • 44
  • 178
  • 308

3 Answers3

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

basin
  • 3,949
  • 2
  • 27
  • 63
Šimon Tóth
  • 35,456
  • 20
  • 106
  • 151
  • 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 – Chandrayya G K Nov 14 '17 at 08:31
1

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

Avihai Marchiano
  • 3,837
  • 3
  • 38
  • 55
  • 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 http://www.eclipse.org/downloads/ a week ago. – fadedbee Jul 25 '12 at 09:39
  • I also created a brand-new project, and it still only has two tabs. – fadedbee Jul 25 '12 at 09: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 '12 at 10:11
  • This was useful for my cross-compiler c project. – Larry Mar 14 '17 at 00:08
0

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

enter image description here

nagylzs
  • 3,954
  • 6
  • 39
  • 70