• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/gcc/
1<html lang="en">
2<head>
3<title>Standards - Using the GNU Compiler Collection (GCC)</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Using the GNU Compiler Collection (GCC)">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="prev" href="G_002b_002b-and-GCC.html#G_002b_002b-and-GCC" title="G++ and GCC">
9<link rel="next" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC">
10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
11<!--
12Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
131998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
142010 Free Software Foundation, Inc.
15
16Permission is granted to copy, distribute and/or modify this document
17under the terms of the GNU Free Documentation License, Version 1.3 or
18any later version published by the Free Software Foundation; with the
19Invariant Sections being ``Funding Free Software'', the Front-Cover
20Texts being (a) (see below), and with the Back-Cover Texts being (b)
21(see below).  A copy of the license is included in the section entitled
22``GNU Free Documentation License''.
23
24(a) The FSF's Front-Cover Text is:
25
26     A GNU Manual
27
28(b) The FSF's Back-Cover Text is:
29
30     You have freedom to copy and modify this GNU Manual, like GNU
31     software.  Copies published by the Free Software Foundation raise
32     funds for GNU development.-->
33<meta http-equiv="Content-Style-Type" content="text/css">
34<style type="text/css"><!--
35  pre.display { font-family:inherit }
36  pre.format  { font-family:inherit }
37  pre.smalldisplay { font-family:inherit; font-size:smaller }
38  pre.smallformat  { font-family:inherit; font-size:smaller }
39  pre.smallexample { font-size:smaller }
40  pre.smalllisp    { font-size:smaller }
41  span.sc    { font-variant:small-caps }
42  span.roman { font-family:serif; font-weight:normal; } 
43  span.sansserif { font-family:sans-serif; font-weight:normal; } 
44--></style>
45<link rel="stylesheet" type="text/css" href="../cs.css">
46</head>
47<body>
48<div class="node">
49<a name="Standards"></a>
50<p>
51Next:&nbsp;<a rel="next" accesskey="n" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a>,
52Previous:&nbsp;<a rel="previous" accesskey="p" href="G_002b_002b-and-GCC.html#G_002b_002b-and-GCC">G++ and GCC</a>,
53Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
54<hr>
55</div>
56
57<h2 class="chapter">2 Language Standards Supported by GCC</h2>
58
59<p>For each language compiled by GCC for which there is a standard, GCC
60attempts to follow one or more versions of that standard, possibly
61with some exceptions, and possibly with some extensions.
62
63<h3 class="section">2.1 C language</h3>
64
65<p><a name="index-C-standard-21"></a><a name="index-C-standards-22"></a><a name="index-ANSI-C-standard-23"></a><a name="index-ANSI-C-24"></a><a name="index-ANSI-C89-25"></a><a name="index-C89-26"></a><a name="index-ANSI-X3_002e159_002d1989-27"></a><a name="index-X3_002e159_002d1989-28"></a><a name="index-ISO-C-standard-29"></a><a name="index-ISO-C-30"></a><a name="index-ISO-C90-31"></a><a name="index-ISO_002fIEC-9899-32"></a><a name="index-ISO-9899-33"></a><a name="index-C90-34"></a><a name="index-ISO-C94-35"></a><a name="index-C94-36"></a><a name="index-ISO-C95-37"></a><a name="index-C95-38"></a><a name="index-ISO-C99-39"></a><a name="index-C99-40"></a><a name="index-ISO-C9X-41"></a><a name="index-C9X-42"></a><a name="index-ISO-C1X-43"></a><a name="index-C1X-44"></a><a name="index-Technical-Corrigenda-45"></a><a name="index-TC1-46"></a><a name="index-Technical-Corrigendum-1-47"></a><a name="index-TC2-48"></a><a name="index-Technical-Corrigendum-2-49"></a><a name="index-TC3-50"></a><a name="index-Technical-Corrigendum-3-51"></a><a name="index-AMD1-52"></a><a name="index-freestanding-implementation-53"></a><a name="index-freestanding-environment-54"></a><a name="index-hosted-implementation-55"></a><a name="index-hosted-environment-56"></a><a name="index-g_t_005f_005fSTDC_005fHOSTED_005f_005f-57"></a>
66GCC supports three versions of the C standard, although support for
67the most recent version is not yet complete.
68
69 <p><a name="index-std-58"></a><a name="index-ansi-59"></a><a name="index-pedantic-60"></a><a name="index-pedantic_002derrors-61"></a>The original ANSI C standard (X3.159-1989) was ratified in 1989 and
70published in 1990.  This standard was ratified as an ISO standard
71(ISO/IEC 9899:1990) later in 1990.  There were no technical
72differences between these publications, although the sections of the
73ANSI standard were renumbered and became clauses in the ISO standard. 
74This standard, in both its forms, is commonly known as <dfn>C89</dfn>, or
75occasionally as <dfn>C90</dfn>, from the dates of ratification.  The ANSI
76standard, but not the ISO standard, also came with a Rationale
77document.  To select this standard in GCC, use one of the options
78<samp><span class="option">-ansi</span></samp>, <samp><span class="option">-std=c90</span></samp> or <samp><span class="option">-std=iso9899:1990</span></samp>; to obtain
79all the diagnostics required by the standard, you should also specify
80<samp><span class="option">-pedantic</span></samp> (or <samp><span class="option">-pedantic-errors</span></samp> if you want them to be
81errors rather than warnings).  See <a href="C-Dialect-Options.html#C-Dialect-Options">Options Controlling C Dialect</a>.
82
83 <p>Errors in the 1990 ISO C standard were corrected in two Technical
84Corrigenda published in 1994 and 1996.  GCC does not support the
85uncorrected version.
86
87 <p>An amendment to the 1990 standard was published in 1995.  This
88amendment added digraphs and <code>__STDC_VERSION__</code> to the language,
89but otherwise concerned the library.  This amendment is commonly known
90as <dfn>AMD1</dfn>; the amended standard is sometimes known as <dfn>C94</dfn> or
91<dfn>C95</dfn>.  To select this standard in GCC, use the option
92<samp><span class="option">-std=iso9899:199409</span></samp> (with, as for other standard versions,
93<samp><span class="option">-pedantic</span></samp> to receive all required diagnostics).
94
95 <p>A new edition of the ISO C standard was published in 1999 as ISO/IEC
969899:1999, and is commonly known as <dfn>C99</dfn>.  GCC has incomplete
97support for this standard version; see
98<a href="http://gcc.gnu.org/gcc-4.6/c99status.html">http://gcc.gnu.org/gcc-4.6/c99status.html</a> for details.  To select this
99standard, use <samp><span class="option">-std=c99</span></samp> or <samp><span class="option">-std=iso9899:1999</span></samp>.  (While in
100development, drafts of this standard version were referred to as
101<dfn>C9X</dfn>.)
102
103 <p>Errors in the 1999 ISO C standard were corrected in three Technical
104Corrigenda published in 2001, 2004 and 2007.  GCC does not support the
105uncorrected version.
106
107 <p>A fourth version of the C standard, known as <dfn>C1X</dfn>, is under
108development; GCC has limited preliminary support for parts of this
109standard, enabled with <samp><span class="option">-std=c1x</span></samp>.
110
111 <p>By default, GCC provides some extensions to the C language that on
112rare occasions conflict with the C standard.  See <a href="C-Extensions.html#C-Extensions">Extensions to the C Language Family</a>.  Use of the
113<samp><span class="option">-std</span></samp> options listed above will disable these extensions where
114they conflict with the C standard version selected.  You may also
115select an extended version of the C language explicitly with
116<samp><span class="option">-std=gnu90</span></samp> (for C90 with GNU extensions), <samp><span class="option">-std=gnu99</span></samp>
117(for C99 with GNU extensions) or <samp><span class="option">-std=gnu1x</span></samp> (for C1X with GNU
118extensions).  The default, if no C language dialect
119options are given, is <samp><span class="option">-std=gnu90</span></samp>; this will change to
120<samp><span class="option">-std=gnu99</span></samp> in some future release when the C99 support is
121complete.  Some features that are part of the C99 standard are
122accepted as extensions in C90 mode.
123
124 <p>The ISO C standard defines (in clause 4) two classes of conforming
125implementation.  A <dfn>conforming hosted implementation</dfn> supports the
126whole standard including all the library facilities; a <dfn>conforming
127freestanding implementation</dfn> is only required to provide certain
128library facilities: those in <code>&lt;float.h&gt;</code>, <code>&lt;limits.h&gt;</code>,
129<code>&lt;stdarg.h&gt;</code>, and <code>&lt;stddef.h&gt;</code>; since AMD1, also those in
130<code>&lt;iso646.h&gt;</code>; and in C99, also those in <code>&lt;stdbool.h&gt;</code> and
131<code>&lt;stdint.h&gt;</code>.  In addition, complex types, added in C99, are not
132required for freestanding implementations.  The standard also defines
133two environments for programs, a <dfn>freestanding environment</dfn>,
134required of all implementations and which may not have library
135facilities beyond those required of freestanding implementations,
136where the handling of program startup and termination are
137implementation-defined, and a <dfn>hosted environment</dfn>, which is not
138required, in which all the library facilities are provided and startup
139is through a function <code>int main (void)</code> or <code>int main (int,
140char *[])</code>.  An OS kernel would be a freestanding environment; a
141program using the facilities of an operating system would normally be
142in a hosted implementation.
143
144 <p><a name="index-ffreestanding-62"></a>GCC aims towards being usable as a conforming freestanding
145implementation, or as the compiler for a conforming hosted
146implementation.  By default, it will act as the compiler for a hosted
147implementation, defining <code>__STDC_HOSTED__</code> as <code>1</code> and
148presuming that when the names of ISO C functions are used, they have
149the semantics defined in the standard.  To make it act as a conforming
150freestanding implementation for a freestanding environment, use the
151option <samp><span class="option">-ffreestanding</span></samp>; it will then define
152<code>__STDC_HOSTED__</code> to <code>0</code> and not make assumptions about the
153meanings of function names from the standard library, with exceptions
154noted below.  To build an OS kernel, you may well still need to make
155your own arrangements for linking and startup. 
156See <a href="C-Dialect-Options.html#C-Dialect-Options">Options Controlling C Dialect</a>.
157
158 <p>GCC does not provide the library facilities required only of hosted
159implementations, nor yet all the facilities required by C99 of
160freestanding implementations; to use the facilities of a hosted
161environment, you will need to find them elsewhere (for example, in the
162GNU C library).  See <a href="Standard-Libraries.html#Standard-Libraries">Standard Libraries</a>.
163
164 <p>Most of the compiler support routines used by GCC are present in
165<samp><span class="file">libgcc</span></samp>, but there are a few exceptions.  GCC requires the
166freestanding environment provide <code>memcpy</code>, <code>memmove</code>,
167<code>memset</code> and <code>memcmp</code>. 
168Finally, if <code>__builtin_trap</code> is used, and the target does
169not implement the <code>trap</code> pattern, then GCC will emit a call
170to <code>abort</code>.
171
172 <p>For references to Technical Corrigenda, Rationale documents and
173information concerning the history of C that is available online, see
174<a href="http://gcc.gnu.org/readings.html">http://gcc.gnu.org/readings.html</a>
175
176<h3 class="section">2.2 C++ language</h3>
177
178<p>GCC supports the ISO C++ standard (1998) and contains experimental
179support for the upcoming ISO C++ standard (200x).
180
181 <p>The original ISO C++ standard was published as the ISO standard (ISO/IEC
18214882:1998) and amended by a Technical Corrigenda published in 2003
183(ISO/IEC 14882:2003). These standards are referred to as C++98 and
184C++03, respectively. GCC implements the majority of C++98 (<code>export</code>
185is a notable exception) and most of the changes in C++03.  To select
186this standard in GCC, use one of the options <samp><span class="option">-ansi</span></samp> or
187<samp><span class="option">-std=c++98</span></samp>; to obtain all the diagnostics required by the
188standard, you should also specify <samp><span class="option">-pedantic</span></samp> (or
189<samp><span class="option">-pedantic-errors</span></samp> if you want them to be errors rather than
190warnings).
191
192 <p>The ISO C++ committee is working on a new ISO C++ standard, dubbed
193C++0x, that is intended to be published by 2009. C++0x contains several
194changes to the C++ language, some of which have been implemented in an
195experimental C++0x mode in GCC. The C++0x mode in GCC tracks the draft
196working paper for the C++0x standard; the latest working paper is
197available on the ISO C++ committee's web site at
198<a href="http://www.open-std.org/jtc1/sc22/wg21/">http://www.open-std.org/jtc1/sc22/wg21/</a>. For information
199regarding the C++0x features available in the experimental C++0x mode,
200see <a href="http://gcc.gnu.org/projects/cxx0x.html">http://gcc.gnu.org/projects/cxx0x.html</a>. To select this
201standard in GCC, use the option <samp><span class="option">-std=c++0x</span></samp>; to obtain all the
202diagnostics required by the standard, you should also specify
203<samp><span class="option">-pedantic</span></samp> (or <samp><span class="option">-pedantic-errors</span></samp> if you want them to be
204errors rather than warnings).
205
206 <p>By default, GCC provides some extensions to the C++ language; See <a href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options">Options Controlling C++ Dialect</a>.  Use of the
207<samp><span class="option">-std</span></samp> option listed above will disable these extensions.  You
208may also select an extended version of the C++ language explicitly with
209<samp><span class="option">-std=gnu++98</span></samp> (for C++98 with GNU extensions) or
210<samp><span class="option">-std=gnu++0x</span></samp> (for C++0x with GNU extensions).  The default, if
211no C++ language dialect options are given, is <samp><span class="option">-std=gnu++98</span></samp>.
212
213<h3 class="section">2.3 Objective-C and Objective-C++ languages</h3>
214
215<p><a name="index-Objective_002dC-63"></a><a name="index-Objective_002dC_002b_002b-64"></a>
216GCC supports &ldquo;traditional&rdquo; Objective-C (also known as &ldquo;Objective-C
2171.0&rdquo;) and contains support for the Objective-C exception and
218synchronization syntax.  It has also support for a number of
219&ldquo;Objective-C 2.0&rdquo; language extensions, including properties, fast
220enumeration (only for Objective-C), method attributes and the
221@optional and @required keywords in protocols.  GCC supports
222Objective-C++ and features available in Objective-C are also available
223in Objective-C++.
224
225 <p>GCC by default uses the GNU Objective-C runtime library, which is part
226of GCC and is not the same as the Apple/NeXT Objective-C runtime
227library used on Apple systems.  There are a number of differences
228documented in this manual.  The options <samp><span class="option">-fgnu-runtime</span></samp> and
229<samp><span class="option">-fnext-runtime</span></samp> allow you to switch between producing output
230that works with the GNU Objective-C runtime library and output that
231works with the Apple/NeXT Objective-C runtime library.
232
233 <p>There is no formal written standard for Objective-C or Objective-C++. 
234The authoritative manual on traditional Objective-C (1.0) is
235&ldquo;Object-Oriented Programming and the Objective-C Language&rdquo;,
236available at a number of web sites:
237     <ul>
238<li><a href="http://www.gnustep.org/resources/documentation/ObjectivCBook.pdf">http://www.gnustep.org/resources/documentation/ObjectivCBook.pdf</a>
239is the original NeXTstep document;
240<li><a href="http://objc.toodarkpark.net">http://objc.toodarkpark.net</a>
241is the same document in another format;
242<li><a href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/">http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/</a>
243has an updated version but make sure you search for &ldquo;Object Oriented Programming and the Objective-C Programming Language 1.0&rdquo;,
244not documentation on the newer &ldquo;Objective-C 2.0&rdquo; language
245</ul>
246
247 <p>The Objective-C exception and synchronization syntax (that is, the
248keywords @try, @throw, @catch, @finally and @synchronized) is
249supported by GCC and is enabled with the option
250<samp><span class="option">-fobjc-exceptions</span></samp>.  The syntax is briefly documented in this
251manual and in the Objective-C 2.0 manuals from Apple.
252
253 <p>The Objective-C 2.0 language extensions and features are automatically
254enabled; they include properties (via the @property, @synthesize and
255@dynamic keywords), fast enumeration (not available in
256Objective-C++), attributes for methods (such as deprecated, noreturn,
257sentinel, format), the unused attribute for method arguments, the
258@package keyword for instance variables and the @optional and
259@required keywords in protocols.  You can disable all these
260Objective-C 2.0 language extensions with the option
261<samp><span class="option">-fobjc-std=objc1</span></samp>, which causes the compiler to recognize the
262same Objective-C language syntax recognized by GCC 4.0, and to produce
263an error if one of the new features is used.
264
265 <p>GCC has currently no support for non-fragile instance variables.
266
267 <p>The authoritative manual on Objective-C 2.0 is available from Apple:
268     <ul>
269<li><a href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/">http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/</a>
270</ul>
271
272 <p>For more information concerning the history of Objective-C that is
273available online, see <a href="http://gcc.gnu.org/readings.html">http://gcc.gnu.org/readings.html</a>
274
275<h3 class="section">2.4 Go language</h3>
276
277<p>The Go language continues to evolve as of this writing; see the
278<a href="http://golang.org/doc/go_spec.html">current language specifications</a>.  At present there are no specific versions of Go, and
279there is no way to describe the language supported by GCC in terms of
280a specific version.  In general GCC tracks the evolving specification
281closely, and any given release will support the language as of the
282date that the release was frozen.
283
284<h3 class="section">2.5 References for other languages</h3>
285
286<p>See <a href="../gnat_rm/index.html#Top">GNAT Reference Manual</a>, for information on standard
287conformance and compatibility of the Ada compiler.
288
289 <p>See <a href="../gfortran/Standards.html#Standards">Standards</a>, for details
290of standards supported by GNU Fortran.
291
292 <p>See <a href="../gcj/Compatibility.html#Compatibility">Compatibility with the Java Platform</a>,
293for details of compatibility between <samp><span class="command">gcj</span></samp> and the Java Platform.
294
295<!-- Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -->
296<!-- 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 -->
297<!-- Free Software Foundation, Inc. -->
298<!-- This is part of the GCC manual. -->
299<!-- For copying conditions, see the file gcc.texi. -->
300 </body></html>
301
302