Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting std=c99 flag in GCC

I was wondering if there were any files in which I could set the -std=c99 flag, so that I would not have to set it for every compilation. I am using GCC 4.4 on Ubuntu.

like image 222
Fatmarik Avatar asked Feb 03 '10 16:02

Fatmarik


People also ask

How do you use std C99 flag?

Instead of calling /usr/bin/gcc , use /usr/bin/c99 . This is the Single-Unix-approved way of invoking a C99 compiler. On an Ubuntu system, this points to a script which invokes gcc after having added the -std=c99 flag, which is precisely what you want.

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).

What is the STD C99 flag?

By setting the flag std=C99 you invoke GCC in a C99 compilant mode... By default GCC does not conform to any standard (but enables all GNU specific extensions), so if you want to compile some standard code you have to set it...

How do I compile my C99?

So to change your makefile to make it compile with C99, you need to change the Makefile in the "build" directory that your makefile is referencing, and add the "-std=c99" at the "gcc" line compiling the source file. CFLAGS is much more common, preferred, and less fragile than editing each invocation of the compiler.


1 Answers

Instead of calling /usr/bin/gcc, use /usr/bin/c99. This is the Single-Unix-approved way of invoking a C99 compiler. On an Ubuntu system, this points to a script which invokes gcc after having added the -std=c99 flag, which is precisely what you want.

like image 188
Thomas Pornin Avatar answered Sep 18 '22 13:09

Thomas Pornin