C99 not default C- version for GCC?

2019-01-15 13:08发布

问题:

Why does not GCC compile the C99 by default? I mean why is it necessary to add --std=c99 flag everytime a code in C99 is written?

回答1:

Edit: As of GCC 5, -std=gnu11 is the default. See Porting to GCC 5.


See C Dialect Options, gnu89 is the default.

`gnu89'

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

As @tsv mentioned, ISO C99 is not fully supported yet:

`c99'
`c9x'
`iso9899:1999'
`iso9899:199x'

ISO C99. Note that this standard is not yet fully supported; see http://gcc.gnu.org/c99status.html for more information. The names `c9x' and `iso9899:199x' are deprecated.

And also:

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



回答2:

Perhaps because it still isn't fully implemented - see C99 status.

It also could be argued C99 features haven't been widely adopted, although that's something of a circular argument.



回答3:

Use the command c99 to compile C programs.

The current POSIX standard specifies the command c99, so it should be available in most Unix-like systems.



回答4:

The reason is that default configurations of gcc take a really long time to be changed, since every time a default configuration is changed, it can potentially break the compilation of valid programs (in this case valid c89 programs which are invalid in c99). Starting with gcc 5.0, the default C standard used by gcc will be gnu11, which is c11 with gnu extensions (see here):

The default mode for C is now -std=gnu11 instead of -std=gnu89.



标签: c gcc c99