Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you configure GCC in Eclipse to use C99?

Tags:

gcc

eclipse

c99

I'm working on a small C project in Eclipse; I just installed Eclipse from the Ubuntu Software Center and added C/C++ Language Support. I can build, run, and debug simple C programs fine.

But I'm using some C99 features now, and Eclipse complains, saying "'for' loop initial declarations are only allowed in C99 mode".

I thought you'd set C99 mode for GCC in the makefile, but the makefile is auto-generated by Eclipse so any changes I make would be overwritten, but I don't see anywhere to put GCC compiler options anywhere in Eclipse's preferences nor my Project Properties windows.

So where do I define C99 mode?

like image 585
Dai Avatar asked Nov 21 '10 03:11

Dai


People also ask

Does GCC use C99?

C99 is substantially completely supported as of GCC 4.5 (with -std=c99 -pedantic-errors used; -fextended-identifiers also needed to enable extended identifiers before GCC 5), modulo bugs and floating-point issues (mainly but not entirely relating to optional C99 features from Annexes F and G).

Can I Run c program in Eclipse?

Eclipse is popular for Java project development. It also supports C/C++, PHP, Python, Perl, and other web project developments via extensible plug-ins. Eclipse is cross-platform and runs under Windows, Linux and Mac OS.


1 Answers

Go into project properties. Search for C/C++Build -> Settings. In the Tool Settings tab search for GCC C compiler and then Miscellaneous. In other flags text box add the -std=c99. It should work fine.

like image 101
Giuseppe Salvatore Avatar answered Nov 03 '22 14:11

Giuseppe Salvatore