C99 not default C- version for GCC?

后端 未结 4 1755
别那么骄傲
别那么骄傲 2020-12-06 17:28

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?

相关标签:
4条回答
  • 2020-12-06 17:51

    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.

    0 讨论(0)
  • 2020-12-06 17:56

    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.

    0 讨论(0)
  • 2020-12-06 17:57

    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.

    0 讨论(0)
  • 2020-12-06 18:07

    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.

    0 讨论(0)
提交回复
热议问题