For each language compiled by GCC for which there is a standard, GCC attempts to follow one or more versions of that standard, possibly with some exceptions, and possibly with some extensions.
The original ANSI C standard (X3.159-1989) was ratified in 1989 and published in 1990. This standard was ratified as an ISO standard (ISO/IEC 9899:1990) later in 1990. There were no technical differences between these publications, although the sections of the ANSI standard were renumbered and became clauses in the ISO standard. The ANSI standard, but not the ISO standard, also came with a Rationale document. This standard, in both its forms, is commonly known as C89 , or occasionally as C90 , from the dates of ratification. To select this standard in GCC, use one of the options -ansi , -std=c90 or -std=iso9899:1990 ; to obtain all the diagnostics required by the standard, you should also specify -pedantic (or -pedantic-errors if you want them to be errors rather than warnings). See Options Controlling C Dialect .
Errors in the 1990 ISO C standard were corrected in two Technical Corrigenda published in 1994 and 1996. GCC does not support the uncorrected version.
An amendment to the 1990 standard was published in 1995. This amendment added digraphs and
to the language, but otherwise concerned the library. This amendment is commonly known as AMD1
; the amended standard is sometimes known as C94
. To select this standard in GCC, use the option
(with, as for other standard versions,
to receive all required diagnostics).
A new edition of the ISO C standard was published in 1999 as ISO/IEC 9899:1999, and is commonly known as C99 . (While in development, drafts of this standard version were referred to as C9X .) GCC has substantially complete support for this standard version; see http://gcc.gnu.org/c99status.html for details. To select this standard, use -std=c99 or -std=iso9899:1999 .
Errors in the 1999 ISO C standard were corrected in three Technical Corrigenda published in 2001, 2004 and 2007. GCC does not support the uncorrected version.
A fourth version of the C standard, known as C11 , was published in 2011 as ISO/IEC 9899:2011. (While in development, drafts of this standard version were referred to as C1X .) GCC has substantially complete support for this standard, enabled with -std=c11 or -std=iso9899:2011 .
By default, GCC provides some extensions to the C language that, on rare occasions conflict with the C standard. See Extensions to the C Language Family . Some features that are part of the C99 standard are accepted as extensions in C90 mode, and some features that are part of the C11 standard are accepted as extensions in C90 and C99 modes. Use of the -std options listed above disables these extensions where they conflict with the C standard version selected. You may also select an extended version of the C language explicitly with -std=gnu90 (for C90 with GNU extensions), -std=gnu99 (for C99 with GNU extensions) or -std=gnu11 (for C11 with GNU extensions).
The default, if no C language dialect options are given, is -std=gnu11 .
The ISO C standard defines (in clause 4) two classes of conforming implementation. A conforming hosted implementation
supports the whole standard including all the library facilities; a conforming freestanding implementation
is only required to provide certain library facilities: those in
; since AMD1, also those in
; since C99, also those in
; and since C11, also those in
. In addition, complex types, added in C99, are not required for freestanding implementations.
The standard also defines two environments for programs, a freestanding environment
, required of all implementations and which may not have library facilities beyond those required of freestanding implementations, where the handling of program startup and termination are implementation-defined; and a hosted environment
, which is not required, in which all the library facilities are provided and startup is through a function
int main (void)
int main (int, char *)
. An OS kernel is an example of a program running in a freestanding environment; a program using the facilities of an operating system is an example of a program running in a hosted environment.
GCC aims towards being usable as a conforming freestanding implementation, or as the compiler for a conforming hosted implementation. By default, it acts as the compiler for a hosted implementation, defining
and presuming that when the names of ISO C functions are used, they have the semantics defined in the standard. To make it act as a conforming freestanding implementation for a freestanding environment, use the option
; it then defines
and does not make assumptions about the meanings of function names from the standard library, with exceptions noted below. To build an OS kernel, you may well still need to make your own arrangements for linking and startup. See Options Controlling C Dialect
GCC does not provide the library facilities required only of hosted implementations, nor yet all the facilities required by C99 of freestanding implementations on all platforms. To use the facilities of a hosted environment, you need to find them elsewhere (for example, in the GNU C library). See Standard Libraries .
Most of the compiler support routines used by GCC are present in
, but there are a few exceptions. GCC requires the freestanding environment provide
. Finally, if
is used, and the target does not implement the
pattern, then GCC emits a call to
For references to Technical Corrigenda, Rationale documents and information concerning the history of C that is available online, see http://gcc.gnu.org/readings.html
GCC supports the original ISO C++ standard published in 1998, and the 2011 and 2014 revisions.
The original ISO C++ standard was published as the ISO standard (ISO/IEC 14882:1998) and amended by a Technical Corrigenda published in 2003 (ISO/IEC 14882:2003). These standards are referred to as C++98 and C++03, respectively. GCC implements the majority of C++98 (
is a notable exception) and most of the changes in C++03. To select this standard in GCC, use one of the options
; to obtain all the diagnostics required by the standard, you should also specify
if you want them to be errors rather than warnings).
A revised ISO C++ standard was published in 2011 as ISO/IEC 14882:2011, and is referred to as C++11; before its publication it was commonly referred to as C++0x. C++11 contains several changes to the C++ language, all of which have been implemented in GCC. For details see https://gcc.gnu.org/projects/cxx0x.html . To select this standard in GCC, use the option -std=c++11 .
Another revised ISO C++ standard was published in 2014 as ISO/IEC 14882:2014, and is referred to as C++14; before its publication it was sometimes referred to as C++1y. C++14 contains several further changes to the C++ language, all of which have been implemented in GCC. For details see https://gcc.gnu.org/projects/cxx1y.html . To select this standard in GCC, use the option -std=c++14 .
GCC also supports the C++ Concepts Technical Specification, ISO/IEC TS 19217:2015, which allows constraints to be defined for templates, allowing template arguments to be checked and for templates to be overloaded or specialized based on the constraints. Support for C++ Concepts is included in an experimental C++1z mode that corresponds to the next revision of the ISO C++ standard, expected to be published in 2017. To enable C++1z support in GCC, use the option -std=c++17 or -std=c++1z .
More information about the C++ standards is available on the ISO C++ committee's web site at http://www.open-std.org/jtc1/sc22/wg21/ .
To obtain all the diagnostics required by any of the standard versions described above you should specify -pedantic or -pedantic-errors , otherwise GCC will allow some non-ISO C++ features as extensions. See Warning Options .
By default, GCC also provides some additional extensions to the C++ language that on rare occasions conflict with the C++ standard. See Options Controlling C++ Dialect . Use of the -std options listed above disables these extensions where they they conflict with the C++ standard version selected. You may also select an extended version of the C++ language explicitly with -std=gnu++98 (for C++98 with GNU extensions), or -std=gnu++11 (for C++11 with GNU extensions), or -std=gnu++14 (for C++14 with GNU extensions), or -std=gnu++1z (for C++1z with GNU extensions).
The default, if no C++ language dialect options are given, is -std=gnu++14 .
GCC supports “traditional” Objective-C (also known as “Objective-C 1.0”) and contains support for the Objective-C exception and synchronization syntax. It has also support for a number of “Objective-C 2.0” language extensions, including properties, fast enumeration (only for Objective-C), method attributes and the @optional and @required keywords in protocols. GCC supports Objective-C++ and features available in Objective-C are also available in Objective-C++.
GCC by default uses the GNU Objective-C runtime library, which is part of GCC and is not the same as the Apple/NeXT Objective-C runtime library used on Apple systems. There are a number of differences documented in this manual. The options -fgnu-runtime and -fnext-runtime allow you to switch between producing output that works with the GNU Objective-C runtime library and output that works with the Apple/NeXT Objective-C runtime library.
There is no formal written standard for Objective-C or Objective-C++. The authoritative manual on traditional Objective-C (1.0) is “Object-Oriented Programming and the Objective-C Language”:
The Objective-C exception and synchronization syntax (that is, the keywords
) is supported by GCC and is enabled with the option
. The syntax is briefly documented in this manual and in the Objective-C 2.0 manuals from Apple.
The Objective-C 2.0 language extensions and features are automatically enabled; they include properties (via the
), fast enumeration (not available in Objective-C++), attributes for methods (such as
attribute for method arguments, the
keyword for instance variables and the
keywords in protocols. You can disable all these Objective-C 2.0 language extensions with the option
, which causes the compiler to recognize the same Objective-C language syntax recognized by GCC 4.0, and to produce an error if one of the new features is used.
GCC has currently no support for non-fragile instance variables.
The authoritative manual on Objective-C 2.0 is available from Apple:
For more information concerning the history of Objective-C that is available online, see http://gcc.gnu.org/readings.html
As of the GCC 4.7.1 release, GCC supports the Go 1 language standard, described at http://golang.org/doc/go1.html .
See GNAT Reference Manual , for information on standard conformance and compatibility of the Ada compiler.
See Standards , for details of standards supported by GNU Fortran.
See Compatibility with the Java Platform , for details of compatibility between gcj and the Java Platform.