]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/doc/standards.texi
Update copyright years.
[thirdparty/gcc.git] / gcc / doc / standards.texi
index f925cde01bd98fc0956459909147d10050753720..f39d8b378f1cdecc33ec11c6d1096e679e353a4b 100644 (file)
@@ -1,9 +1,15 @@
-@c Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+@c Copyright (C) 2000-2020 Free Software Foundation, Inc.
 @c This is part of the GCC manual.
 @c For copying conditions, see the file gcc.texi.
 
 @node Standards
 @chapter Language Standards Supported by GCC
+
+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.
+
+@section C Language
 @cindex C standard
 @cindex C standards
 @cindex ANSI C standard
 @cindex C99
 @cindex ISO C9X
 @cindex C9X
+@cindex ISO C11
+@cindex C11
+@cindex ISO C1X
+@cindex C1X
+@cindex ISO C17
+@cindex C17
+@cindex ISO C2X
+@cindex C2X
 @cindex Technical Corrigenda
 @cindex TC1
 @cindex Technical Corrigendum 1
 @cindex TC2
 @cindex Technical Corrigendum 2
+@cindex TC3
+@cindex Technical Corrigendum 3
 @cindex AMD1
 @cindex freestanding implementation
 @cindex freestanding environment
 @cindex hosted environment
 @findex __STDC_HOSTED__
 
-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.
-
-GCC supports three versions of the C standard, although support for
-the most recent version is not yet complete.
-
 @opindex std
 @opindex ansi
 @opindex pedantic
@@ -54,11 +63,13 @@ 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.
-This standard, in both its forms, is commonly known as @dfn{C89}, or
-occasionally as @dfn{C90}, from the dates of ratification.  The ANSI
+The ANSI
 standard, but not the ISO standard, also came with a Rationale
-document.  To select this standard in GCC, use one of the options
-@option{-ansi}, @option{-std=c89} or @option{-std=iso9899:1990}; to obtain
+document.  
+This standard, in both its forms, is commonly known as @dfn{C89}, or
+occasionally as @dfn{C90}, from the dates of ratification.
+To select this standard in GCC, use one of the options
+@option{-ansi}, @option{-std=c90} or @option{-std=iso9899:1990}; to obtain
 all the diagnostics required by the standard, you should also specify
 @option{-pedantic} (or @option{-pedantic-errors} if you want them to be
 errors rather than warnings).  @xref{C Dialect Options,,Options
@@ -77,29 +88,49 @@ as @dfn{AMD1}; the amended standard is sometimes known as @dfn{C94} or
 @option{-pedantic} 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 @dfn{C99}.  GCC has incomplete
-support for this standard version; see
-@uref{http://gcc.gnu.org/c99status.html} for details.  To select this
-standard, use @option{-std=c99} or @option{-std=iso9899:1999}.  (While in
+9899:1999, and is commonly known as @dfn{C99}.  (While in
 development, drafts of this standard version were referred to as
-@dfn{C9X}.)
+@dfn{C9X}.)  GCC has substantially
+complete support for this standard version; see
+@uref{http://gcc.gnu.org/c99status.html} for details.  To select this
+standard, use @option{-std=c99} or @option{-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 @dfn{C11}, was published
+in 2011 as ISO/IEC 9899:2011.  (While in development, drafts of this
+standard version were referred to as @dfn{C1X}.)
+GCC has substantially complete support
+for this standard, enabled with @option{-std=c11} or
+@option{-std=iso9899:2011}.  A version with corrections integrated was
+prepared in 2017 and published in 2018 as ISO/IEC 9899:2018; it is
+known as @dfn{C17} and is supported with @option{-std=c17} or
+@option{-std=iso9899:2017}; the corrections are also applied with
+@option{-std=c11}, and the only difference between the options is the
+value of @code{__STDC_VERSION__}.
 
-Errors in the 1999 ISO C standard were corrected in a Technical
-Corrigendum published in 2001.  GCC does not support the uncorrected
-version.
+A further version of the C standard, known as @dfn{C2X}, is under
+development; experimental and incomplete support for this is enabled
+with @option{-std=c2x}.
 
-By default, GCC provides some extensions to the C language that on
+By default, GCC provides some extensions to the C language that, on
 rare occasions conflict with the C standard.  @xref{C
-Extensions,,Extensions to the C Language Family}.  Use of the
-@option{-std} options listed above will disable these extensions where
+Extensions,,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
+@option{-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
-@option{-std=gnu89} (for C89 with GNU extensions) or @option{-std=gnu99}
-(for C99 with GNU extensions).  The default, if no C language dialect
-options are given, is @option{-std=gnu89}; this will change to
-@option{-std=gnu99} in some future release when the C99 support is
-complete.  Some features that are part of the C99 standard are
-accepted as extensions in C89 mode.
+@option{-std=gnu90} (for C90 with GNU extensions), @option{-std=gnu99}
+(for C99 with GNU extensions) or @option{-std=gnu11} (for C11 with GNU
+extensions).  
+
+The default, if no C language dialect options are given,
+is @option{-std=gnu11}.  
 
 The ISO C standard defines (in clause 4) two classes of conforming
 implementation.  A @dfn{conforming hosted implementation} supports the
@@ -107,30 +138,33 @@ whole standard including all the library facilities; a @dfn{conforming
 freestanding implementation} is only required to provide certain
 library facilities: those in @code{<float.h>}, @code{<limits.h>},
 @code{<stdarg.h>}, and @code{<stddef.h>}; since AMD1, also those in
-@code{<iso646.h>}; and in C99, also those in @code{<stdbool.h>} and
-@code{<stdint.h>}.  In addition, complex types, added in C99, are not
-required for freestanding implementations.  The standard also defines
-two environments for programs, a @dfn{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 @dfn{hosted environment}, which is not
-required, in which all the library facilities are provided and startup
-is through a function @code{int main (void)} or @code{int main (int,
-char *[])}.  An OS kernel would be a freestanding environment; a
-program using the facilities of an operating system would normally be
-in a hosted implementation.
+@code{<iso646.h>}; since C99, also those in @code{<stdbool.h>} and
+@code{<stdint.h>}; and since C11, also those in @code{<stdalign.h>}
+and @code{<stdnoreturn.h>}.  In addition, complex types, added in C99, are not
+required for freestanding implementations.  
+
+The standard also defines two environments for programs, a
+@dfn{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 @dfn{hosted
+environment}, which is not required, in which all the library
+facilities are provided and startup is through a function @code{int
+main (void)} or @code{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.
 
 @opindex ffreestanding
 GCC aims towards being usable as a conforming freestanding
 implementation, or as the compiler for a conforming hosted
-implementation.  By default, it will act as the compiler for a hosted
+implementation.  By default, it acts as the compiler for a hosted
 implementation, defining @code{__STDC_HOSTED__} as @code{1} 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 @option{-ffreestanding}; it will then define
-@code{__STDC_HOSTED__} to @code{0} and not make assumptions about the
+option @option{-ffreestanding}; it then defines
+@code{__STDC_HOSTED__} to @code{0} 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.
@@ -138,47 +172,165 @@ your own arrangements for linking and startup.
 
 GCC does not provide the library facilities required only of hosted
 implementations, nor yet all the facilities required by C99 of
-freestanding implementations; to use the facilities of a hosted
-environment, you will need to find them elsewhere (for example, in the
+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).  @xref{Standard Libraries,,Standard Libraries}.
 
 Most of the compiler support routines used by GCC are present in
 @file{libgcc}, but there are a few exceptions.  GCC requires the
 freestanding environment provide @code{memcpy}, @code{memmove},
-@code{memset} and @code{memcmp}.  Some older ports of GCC are 
-configured to use the BSD @code{bcopy}, @code{bzero} and @code{bcmp}
-functions instead, but this is deprecated for new ports.
-Finally, if @code{__builtin_trap} is used, and the target does 
-not implement the @code{trap} pattern, then GCC will emit a call
+@code{memset} and @code{memcmp}.
+Finally, if @code{__builtin_trap} is used, and the target does
+not implement the @code{trap} pattern, then GCC emits a call
 to @code{abort}.
 
 For references to Technical Corrigenda, Rationale documents and
 information concerning the history of C that is available online, see
 @uref{http://gcc.gnu.org/readings.html}
 
-@c FIXME: details of C++ standard.
+@section C++ Language
+
+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 (@code{export}
+is a notable exception) and most of the changes in C++03.  To select
+this standard in GCC, use one of the options @option{-ansi},
+@option{-std=c++98}, or @option{-std=c++03}; to obtain all the diagnostics
+required by the standard, you should also specify @option{-pedantic} (or
+@option{-pedantic-errors} 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 @uref{https://gcc.gnu.org/projects/@/cxx-status.html#cxx11}.
+To select this standard in GCC, use the option @option{-std=c++11}.
 
-There is no formal written standard for Objective-C@.  The most
-authoritative manual is ``Object-Oriented Programming and the
-Objective-C Language'', available at a number of web sites;
-@uref{http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/} has a
-recent version, while @uref{http://www.toodarkpark.org/computers/objc/}
-is an older example.  @uref{http://www.gnustep.org} includes useful
-information as well.
+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 @uref{https://gcc.gnu.org/projects/@/cxx-status.html#cxx14}.
+To select this standard in GCC, use the option @option{-std=c++14}.
 
-@cindex treelang
-There is no standard for treelang, which is a sample language front end
-for GCC. Its only purpose is as a sample for people wishing to write a
-new language for GCC. The language is documented in
-@file{gcc/treelang/treelang.texi} which can be turned into info or
-HTML format.
+The C++ language was further revised in 2017 and ISO/IEC 14882:2017 was
+published.  This is referred to as C++17, and before publication was
+often referred to as C++1z.  GCC supports all the changes in the new
+specification.  For further details see
+@uref{https://gcc.gnu.org/projects/@/cxx-status.html#cxx1z}.  Use the option
+@option{-std=c++17} to select this variant of C++.
+
+More information about the C++ standards is available on the ISO C++
+committee's web site at @uref{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 @option{-pedantic}
+or @option{-pedantic-errors}, otherwise GCC will allow some non-ISO C++
+features as extensions. @xref{Warning Options}.
+
+By default, GCC also provides some additional extensions to the C++ language
+that on rare occasions conflict with the C++ standard.  @xref{C++
+Dialect Options,Options Controlling C++ Dialect}.  Use of the
+@option{-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
+@option{-std=gnu++98} (for C++98 with GNU extensions), or
+@option{-std=gnu++11} (for C++11 with GNU extensions), or
+@option{-std=gnu++14} (for C++14 with GNU extensions), or
+@option{-std=gnu++17} (for C++17 with GNU extensions).  
+
+The default, if
+no C++ language dialect options are given, is @option{-std=gnu++14}.
+
+@section Objective-C and Objective-C++ Languages
+@cindex Objective-C
+@cindex Objective-C++
+
+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 @option{-fgnu-runtime} and
+@option{-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'':
+@uref{http://www.gnustep.org/@/resources/@/documentation/@/ObjectivCBook.pdf}
+is the original NeXTstep document.
+
+The Objective-C exception and synchronization syntax (that is, the
+keywords @code{@@try}, @code{@@throw}, @code{@@catch},
+@code{@@finally} and @code{@@synchronized}) is
+supported by GCC and is enabled with the option
+@option{-fobjc-exceptions}.  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 @code{@@property},
+@code{@@synthesize} and
+@code{@@dynamic keywords}), fast enumeration (not available in
+Objective-C++), attributes for methods (such as @code{deprecated},
+@code{noreturn}, @code{sentinel}, @code{format}),
+the @code{unused} attribute for method arguments, the
+@code{@@package} keyword for instance variables and the @code{@@optional} and
+@code{@@required} keywords in protocols.  You can disable all these
+Objective-C 2.0 language extensions with the option
+@option{-fobjc-std=objc1}, 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:
+@itemize
+@item
+@uref{https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html}
+@end itemize
+
+For more information concerning the history of Objective-C that is
+available online, see @uref{http://gcc.gnu.org/readings.html}
+
+@section Go Language
+
+As of the GCC 4.7.1 release, GCC supports the Go 1 language standard,
+described at @uref{https://golang.org/doc/go1}.
+
+@section HSA Intermediate Language (HSAIL)
+
+GCC can compile the binary representation (BRIG) of the HSAIL text format as
+described in HSA Programmer's Reference Manual version 1.0.1. This
+capability is typically utilized to implement the HSA runtime API's HSAIL 
+finalization extension for a gcc supported processor. HSA standards are
+freely available at @uref{http://www.hsafoundation.com/standards/}.
+
+@section D language
+
+GCC supports the D 2.0 programming language.  The D language itself is
+currently defined by its reference implementation and supporting language
+specification, described at @uref{https://dlang.org/spec/spec.html}.
+
+@section References for Other Languages
 
 @xref{Top, GNAT Reference Manual, About This Guide, gnat_rm,
 GNAT Reference Manual}, for information on standard
 conformance and compatibility of the Ada compiler.
 
-@xref{Language,,The GNU Fortran Language, g77, Using and Porting GNU
-Fortran}, for details of the Fortran language supported by GCC@.
-
-@xref{Compatibility,,Compatibility with the Java Platform, gcj, GNU gcj},
-for details of compatibility between @code{gcj} and the Java Platform.
+@xref{Standards,,Standards, gfortran, The GNU Fortran Compiler}, for details
+of standards supported by GNU Fortran.