When I ask to see the current version of cc I get this.
$ cc --version cc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $
What I would like to know is which of c89, c90, c99 or c11 is being used.
The latest version of GCC, which is 9.1. 0 is available from the Ubuntu Toolchain PPA.
GCC supports “traditional” Objective-C (also known as “Objective-C 1.0”) and contains support for the Objective-C exception and synchronization syntax.
gcc(GNU Compiler Collection) is one of the most widely used C compilers . Ubuntu uses gcc and is installed by default when you install it on your system.
The gcc package is installed by default on all Ubuntu desktop flavors.
This is explained in depth in the gcc manual, available (if it's installed) by typing info gcc
or online here. The relevant section of the 4.7.2 manual is here.
By default, gcc does not conform to any of the ANSI/ISO C standards. The current default is equivalent to -std=gnu90
, which is the 1989/1990 standard with GNU-specific extensions. (Some diagnostics required by the language standard are not issued.) Version 5.1.0, released 2015-04-22, changed the default from -std=gnu90
to -std=gnu11
, as documented here.
If you want standard conformance, you can use any of the following:
-std=c90 -pedantic -std=c99 -pedantic -std=c11 -pedantic
-std=c90
can also be spelled -ansi
, -std=c89
, or -std=iso9899:1990
.
-std=iso9899:199409
supports the C90 standard plus the 1995 amendment, which added a few minor features (all of which are also in C99).
-std=c99
can also be spelled -std=c9x
or -std=iso9899:1999
(the name c9x
was used before the standard was published). C99 support is not quite complete, but it's close.
-std=c11
can also be spelled -std=c0x
or -std=iso9899:2011
(the name c0x
was used before the final standard was published; it was wrongly assumed that x
would not exceed 9). C11 support is also incomplete; the current status is summarized here.
The -pedantic
option causes gcc to print required diagnostics for violations of constraints and syntax rules. In some cases, those diagnostics are merely warnings -- and there's no easy way to distinguish between those warnings and other warnings that aren't required by the language. Replace -pedantic
by -pedantic-errors
to cause gcc to treat language violations as fatal errors.
A quick history of the standard:
__STDC_VERSION__
and __STDC_LIB_EXT1__
.ANSI did not issue its own versions of the 1999 or 2011 standards, adopting the ISO standards instead.
N1256 is a freely available draft of the C99 standard, with the 3 Technical Corrigenda merged into it.
N1570 is a freely available draft of the C11 standard. There are some minor differences between it and the published C11 standard, plus one Technical Corrigendum. For more details, see my answer to this question.
useful information from info gcc
for gcc6 and https://gcc.gnu.org/onlinedocs/gcc-5.4.0/gcc/Standards.html#Standards for gcc5
6.3.1
- 10.1.0
2.1 C Language ============== The default, if no C language dialect options are given, is '-std=gnu11'. 2.2 C++ Language ================ The default, if no C++ language dialect options are given, is '-std=gnu++14'.
5.4.0
2.1 C Language ============== The default, if no C language dialect options are given, is -std=gnu11 2.2 C++ Language ================ The default, if no C++ language dialect options are given, is -std=gnu++98
For C, default mode remains std=gnu11
, but for C++ it has jumped from std=gnu++98
to std=gnu++14
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With