tags:

views:

407

answers:

2

Hello,

I am using gcc 4.4.2 on linux

I am just wondering does gcc automatically default to compiling with c99 as its the latest standard?

How can I specify if I want to compile with c89 or c99?

Many thanks for any advice,

+1  A: 

One reason not to use C99 by default is because this standard is not fully implemented in the compiler yet. However, I believe that you can set the default mode when compiling gcc, so if the choice of standards really matters for you, it's better always to pass the option.

The options are -std=c99 and -std=c89 respectively.

Pascal Cuoq
I normally compile with c89 as its more portable. But there are some features of c99 that I like. However, I can't use c99 standard as I need to compile on windows using VS, which only supports c89. Even the latest version of VS 2010 will not be implementing c89.
robUK
+6  A: 

From the gcc(1) man page:

   -std=
       Determine the language standard.   This option is currently only
       supported when compiling C or C++.

....

       c99
       c9x
       iso9899:1999
       iso9899:199x
           ISO C99.  Note that this standard is not yet fully supported;
           see <http://gcc.gnu.org/gcc-4.4/c99status.html&gt; for more
           information.  The names c9x and iso9899:199x are deprecated.

       gnu89
           GNU dialect of ISO C90 (including some C99 features). This is
           the default for C code.

       gnu99
       gnu9x
           GNU dialect of ISO C99.  When ISO C99 is fully implemented in
           GCC, this will become the default.  The name gnu9x is
           deprecated.
Ignacio Vazquez-Abrams