gcc: Standards

1 
1 2 Language Standards Supported by GCC
1 *************************************
1 
1 For each language compiled by GCC for which there is a standard, GCC
1 attempts to follow one or more versions of that standard, possibly with
1 some exceptions, and possibly with some extensions.
1 
1 2.1 C Language
1 ==============
1 
1 The original ANSI C standard (X3.159-1989) was ratified in 1989 and
1 published in 1990.  This standard was ratified as an ISO standard
1 (ISO/IEC 9899:1990) later in 1990.  There were no technical differences
1 between these publications, although the sections of the ANSI standard
1 were renumbered and became clauses in the ISO standard.  The ANSI
1 standard, but not the ISO standard, also came with a Rationale document.
1 This standard, in both its forms, is commonly known as "C89", or
1 occasionally as "C90", from the dates of ratification.  To select this
1 standard in GCC, use one of the options '-ansi', '-std=c90' or
1 '-std=iso9899:1990'; to obtain all the diagnostics required by the
1 standard, you should also specify '-pedantic' (or '-pedantic-errors' if
11 you want them to be errors rather than warnings).  ⇒Options
 Controlling C Dialect C Dialect Options.
1 
1  Errors in the 1990 ISO C standard were corrected in two Technical
1 Corrigenda published in 1994 and 1996.  GCC does not support the
1 uncorrected version.
1 
1  An amendment to the 1990 standard was published in 1995.  This
1 amendment added digraphs and '__STDC_VERSION__' to the language, but
1 otherwise concerned the library.  This amendment is commonly known as
1 "AMD1"; the amended standard is sometimes known as "C94" or "C95".  To
1 select this standard in GCC, use the option '-std=iso9899:199409' (with,
1 as for other standard versions, '-pedantic' to receive all required
1 diagnostics).
1 
1  A new edition of the ISO C standard was published in 1999 as ISO/IEC
1 9899:1999, and is commonly known as "C99".  (While in development,
1 drafts of this standard version were referred to as "C9X".) GCC has
1 substantially complete support for this standard version; see
1 <http://gcc.gnu.org/c99status.html> for details.  To select this
1 standard, use '-std=c99' or '-std=iso9899:1999'.
1 
1  Errors in the 1999 ISO C standard were corrected in three Technical
1 Corrigenda published in 2001, 2004 and 2007.  GCC does not support the
1 uncorrected version.
1 
1  A fourth version of the C standard, known as "C11", was published in
1 2011 as ISO/IEC 9899:2011.  (While in development, drafts of this
1 standard version were referred to as "C1X".) GCC has substantially
1 complete support for this standard, enabled with '-std=c11' or
1 '-std=iso9899:2011'.  A version with corrections integrated is known as
1 "C17" and is supported with '-std=c17' or '-std=iso9899:2017'; the
1 corrections are also applied with '-std=c11', and the only difference
1 between the options is the value of '__STDC_VERSION__'.
1 
1  By default, GCC provides some extensions to the C language that, on
11 rare occasions conflict with the C standard.  ⇒Extensions to the C
 Language Family C Extensions.  Some features that are part of the C99
1 standard are accepted as extensions in C90 mode, and some features that
1 are part of the C11 standard are accepted as extensions in C90 and C99
1 modes.  Use of the '-std' options listed above disables these extensions
1 where they conflict with the C standard version selected.  You may also
1 select an extended version of the C language explicitly with
1 '-std=gnu90' (for C90 with GNU extensions), '-std=gnu99' (for C99 with
1 GNU extensions) or '-std=gnu11' (for C11 with GNU extensions).
1 
1  The default, if no C language dialect options are given, is
1 '-std=gnu11'.
1 
1  The ISO C standard defines (in clause 4) two classes of conforming
1 implementation.  A "conforming hosted implementation" supports the whole
1 standard including all the library facilities; a "conforming
1 freestanding implementation" is only required to provide certain library
1 facilities: those in '<float.h>', '<limits.h>', '<stdarg.h>', and
1 '<stddef.h>'; since AMD1, also those in '<iso646.h>'; since C99, also
1 those in '<stdbool.h>' and '<stdint.h>'; and since C11, also those in
1 '<stdalign.h>' and '<stdnoreturn.h>'.  In addition, complex types, added
1 in C99, are not required for freestanding implementations.
1 
1  The standard also defines two environments for programs, a
1 "freestanding environment", required of all implementations and which
1 may not have library facilities beyond those required of freestanding
1 implementations, where the handling of program startup and termination
1 are implementation-defined; and a "hosted environment", which is not
1 required, in which all the library facilities are provided and startup
1 is through a function 'int main (void)' or 'int main (int, char *[])'.
1 An OS kernel is an example of a program running in a freestanding
1 environment; a program using the facilities of an operating system is an
1 example of a program running in a hosted environment.
1 
1  GCC aims towards being usable as a conforming freestanding
1 implementation, or as the compiler for a conforming hosted
1 implementation.  By default, it acts as the compiler for a hosted
1 implementation, defining '__STDC_HOSTED__' as '1' and presuming that
1 when the names of ISO C functions are used, they have the semantics
1 defined in the standard.  To make it act as a conforming freestanding
1 implementation for a freestanding environment, use the option
1 '-ffreestanding'; it then defines '__STDC_HOSTED__' to '0' and does not
1 make assumptions about the meanings of function names from the standard
1 library, with exceptions noted below.  To build an OS kernel, you may
1 well still need to make your own arrangements for linking and startup.
1 ⇒Options Controlling C Dialect C Dialect Options.
1 
1  GCC does not provide the library facilities required only of hosted
1 implementations, nor yet all the facilities required by C99 of
1 freestanding implementations on all platforms.  To use the facilities of
1 a hosted environment, you need to find them elsewhere (for example, in
1 the GNU C library).  ⇒Standard Libraries Standard Libraries.
1 
1  Most of the compiler support routines used by GCC are present in
1 'libgcc', but there are a few exceptions.  GCC requires the freestanding
1 environment provide 'memcpy', 'memmove', 'memset' and 'memcmp'.
1 Finally, if '__builtin_trap' is used, and the target does not implement
1 the 'trap' pattern, then GCC emits a call to 'abort'.
1 
1  For references to Technical Corrigenda, Rationale documents and
1 information concerning the history of C that is available online, see
1 <http://gcc.gnu.org/readings.html>
1 
1 2.2 C++ Language
1 ================
1 
1 GCC supports the original ISO C++ standard published in 1998, and the
1 2011 and 2014 revisions.
1 
1  The original ISO C++ standard was published as the ISO standard
1 (ISO/IEC 14882:1998) and amended by a Technical Corrigenda published in
1 2003 (ISO/IEC 14882:2003).  These standards are referred to as C++98 and
1 C++03, respectively.  GCC implements the majority of C++98 ('export' is
1 a notable exception) and most of the changes in C++03.  To select this
1 standard in GCC, use one of the options '-ansi', '-std=c++98', or
1 '-std=c++03'; to obtain all the diagnostics required by the standard,
1 you should also specify '-pedantic' (or '-pedantic-errors' if you want
1 them to be errors rather than warnings).
1 
1  A revised ISO C++ standard was published in 2011 as ISO/IEC 14882:2011,
1 and is referred to as C++11; before its publication it was commonly
1 referred to as C++0x.  C++11 contains several changes to the C++
1 language, all of which have been implemented in GCC.  For details see
1 <https://gcc.gnu.org/projects/cxx-status.html#cxx11>.  To select this
1 standard in GCC, use the option '-std=c++11'.
1 
1  Another revised ISO C++ standard was published in 2014 as ISO/IEC
1 14882:2014, and is referred to as C++14; before its publication it was
1 sometimes referred to as C++1y.  C++14 contains several further changes
1 to the C++ language, all of which have been implemented in GCC.  For
1 details see <https://gcc.gnu.org/projects/cxx-status.html#cxx14>.  To
1 select this standard in GCC, use the option '-std=c++14'.
1 
1  The C++ language was further revised in 2017 and ISO/IEC 14882:2017 was
1 published.  This is referred to as C++17, and before publication was
1 often referred to as C++1z.  GCC supports all the changes in the new
1 specification.  For further details see
1 <https://gcc.gnu.org/projects/cxx-status.html#cxx1z>.  Use the option
1 '-std=c++17' to select this variant of C++.
1 
1  More information about the C++ standards is available on the ISO C++
1 committee's web site at <http://www.open-std.org/jtc1/sc22/wg21/>.
1 
1  To obtain all the diagnostics required by any of the standard versions
1 described above you should specify '-pedantic' or '-pedantic-errors',
11 otherwise GCC will allow some non-ISO C++ features as extensions.  ⇒
 Warning Options.
1 
1  By default, GCC also provides some additional extensions to the C++
11 language that on rare occasions conflict with the C++ standard.  ⇒
 Options Controlling C++ Dialect C++ Dialect Options.  Use of the '-std'
1 options listed above disables these extensions where they they conflict
1 with the C++ standard version selected.  You may also select an extended
1 version of the C++ language explicitly with '-std=gnu++98' (for C++98
1 with GNU extensions), or '-std=gnu++11' (for C++11 with GNU extensions),
1 or '-std=gnu++14' (for C++14 with GNU extensions), or '-std=gnu++17'
1 (for C++17 with GNU extensions).
1 
1  The default, if no C++ language dialect options are given, is
1 '-std=gnu++14'.
1 
1 2.3 Objective-C and Objective-C++ Languages
1 ===========================================
1 
1 GCC supports "traditional" Objective-C (also known as "Objective-C 1.0")
1 and contains support for the Objective-C exception and synchronization
1 syntax.  It has also support for a number of "Objective-C 2.0" language
1 extensions, including properties, fast enumeration (only for
1 Objective-C), method attributes and the @optional and @required keywords
1 in protocols.  GCC supports Objective-C++ and features available in
1 Objective-C are also available in Objective-C++.
1 
1  GCC by default uses the GNU Objective-C runtime library, which is part
1 of GCC and is not the same as the Apple/NeXT Objective-C runtime library
1 used on Apple systems.  There are a number of differences documented in
1 this manual.  The options '-fgnu-runtime' and '-fnext-runtime' allow you
1 to switch between producing output that works with the GNU Objective-C
1 runtime library and output that works with the Apple/NeXT Objective-C
1 runtime library.
1 
1  There is no formal written standard for Objective-C or Objective-C++.
1 The authoritative manual on traditional Objective-C (1.0) is
1 "Object-Oriented Programming and the Objective-C Language":
1 <http://www.gnustep.org/resources/documentation/ObjectivCBook.pdf> is
1 the original NeXTstep document.
1 
1  The Objective-C exception and synchronization syntax (that is, the
1 keywords '@try', '@throw', '@catch', '@finally' and '@synchronized') is
1 supported by GCC and is enabled with the option '-fobjc-exceptions'.
1 The syntax is briefly documented in this manual and in the Objective-C
1 2.0 manuals from Apple.
1 
1  The Objective-C 2.0 language extensions and features are automatically
1 enabled; they include properties (via the '@property', '@synthesize' and
1 '@dynamic keywords'), fast enumeration (not available in Objective-C++),
1 attributes for methods (such as 'deprecated', 'noreturn', 'sentinel',
1 'format'), the 'unused' attribute for method arguments, the '@package'
1 keyword for instance variables and the '@optional' and '@required'
1 keywords in protocols.  You can disable all these Objective-C 2.0
1 language extensions with the option '-fobjc-std=objc1', which causes the
1 compiler to recognize the same Objective-C language syntax recognized by
1 GCC 4.0, and to produce an error if one of the new features is used.
1 
1  GCC has currently no support for non-fragile instance variables.
1 
1  The authoritative manual on Objective-C 2.0 is available from Apple:
1    * 
1      <https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html>
1 
1  For more information concerning the history of Objective-C that is
1 available online, see <http://gcc.gnu.org/readings.html>
1 
1 2.4 Go Language
1 ===============
1 
1 As of the GCC 4.7.1 release, GCC supports the Go 1 language standard,
1 described at <https://golang.org/doc/go1>.
1 
1 2.5 HSA Intermediate Language (HSAIL)
1 =====================================
1 
1 GCC can compile the binary representation (BRIG) of the HSAIL text
1 format as described in HSA Programmer's Reference Manual version 1.0.1.
1 This capability is typically utilized to implement the HSA runtime API's
1 HSAIL finalization extension for a gcc supported processor.  HSA
1 standards are freely available at
1 <http://www.hsafoundation.com/standards/>.
1 
1 2.6 References for Other Languages
1 ==================================
1 
1 ⇒GNAT Reference Manual (gnat_rm)Top, for information on standard
1 conformance and compatibility of the Ada compiler.
1 
1  ⇒Standards (gfortran)Standards, for details of standards
1 supported by GNU Fortran.
1