How do I know which ANSI C standard my gcc works with by default?

I read here , this is the C90 with extensions. How can I know for sure?

+5
source share
5 answers

Use the flag -std=to indicate dialect: c89, c99, c++98etc. Note that is c90equivalent c89.

How abbreviated -ansicalls -std=c89in C mode and -std=c++98C ++ mode.

Use -pedanticto enable all diagnostics required by standards.

The default values ​​are gnu89for C and gnu++98for C ++. Refer to the manual for a detailed description of the various dialects.

+3

. (OSX 10.7, gcc 4.2.1 ( Apple Inc., 5658) (LLVM build 2335.15.00)):

-std =
    .     C ++.

    ; :

....

    gnu89
        , ISO C90 GNU ( C99).

....

    GNU ++ 98
        , -std = ++ 98 GNU. ++.

+6

std

gcc -v --help | less

gcc.

+3

, , GCC ANSI C (STRICT__ANSI) (.. - cli).

0

gcc ANSI ISO C . -std=gnuNN, GNU- . 5 ( ) -std=gnu90. 5, -std=gnu11.

ISO C: C90, C99 C11. (C95 C90.) ANSI C 1989 C89; , ISO C90.

gcc,

 info gcc

" ".

, ​​ gcc, , info gcc, gcc, , , " " , . gcc -.

,

gcc --version

, , GCC online documentation , .

More simply, if you have a version prior to 5.0, the default is -std=gnu89; otherwise, the default value is -std=gnu11. (This may change in a future version, but only some time after the publication of the new ISO C standard, and the gcc developers managed to implement it and decided to do it by default. Do not hold your breath.)

Or you can completely avoid the issue by specifying the version you need using the command line option -std=....

0
source

All Articles