~ubuntu-branches/debian/stretch/gcc-6-doc/stretch

« back to all changes in this revision

Viewing changes to .pc/from-debian-gcc-gdc-6-doc.diff/gcc/doc/standards.texi

  • Committer: Package Import Robot
  • Author(s): Guo Yixuan (郭溢譞)
  • Date: 2016-05-06 21:45:33 UTC
  • Revision ID: package-import@ubuntu.com-20160506214533-1ro717riyxkhd4kn
Tags: 6.1.0-1
* New upstream branch. (Closes: #822667)
* Synced patches with gcc-6, 6.1.1-1.
* Use https URIs for Vcs-*.
* Bumped standards version to 3.9.8, no changes needed.
* Update debian/copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
@c Copyright (C) 2000-2016 Free Software Foundation, Inc.
 
2
@c This is part of the GCC manual.
 
3
@c For copying conditions, see the file gcc.texi.
 
4
 
 
5
@node Standards
 
6
@chapter Language Standards Supported by GCC
 
7
 
 
8
For each language compiled by GCC for which there is a standard, GCC
 
9
attempts to follow one or more versions of that standard, possibly
 
10
with some exceptions, and possibly with some extensions.
 
11
 
 
12
@section C Language
 
13
@cindex C standard
 
14
@cindex C standards
 
15
@cindex ANSI C standard
 
16
@cindex ANSI C
 
17
@cindex ANSI C89
 
18
@cindex C89
 
19
@cindex ANSI X3.159-1989
 
20
@cindex X3.159-1989
 
21
@cindex ISO C standard
 
22
@cindex ISO C
 
23
@cindex ISO C90
 
24
@cindex ISO/IEC 9899
 
25
@cindex ISO 9899
 
26
@cindex C90
 
27
@cindex ISO C94
 
28
@cindex C94
 
29
@cindex ISO C95
 
30
@cindex C95
 
31
@cindex ISO C99
 
32
@cindex C99
 
33
@cindex ISO C9X
 
34
@cindex C9X
 
35
@cindex ISO C11
 
36
@cindex C11
 
37
@cindex ISO C1X
 
38
@cindex C1X
 
39
@cindex Technical Corrigenda
 
40
@cindex TC1
 
41
@cindex Technical Corrigendum 1
 
42
@cindex TC2
 
43
@cindex Technical Corrigendum 2
 
44
@cindex TC3
 
45
@cindex Technical Corrigendum 3
 
46
@cindex AMD1
 
47
@cindex freestanding implementation
 
48
@cindex freestanding environment
 
49
@cindex hosted implementation
 
50
@cindex hosted environment
 
51
@findex __STDC_HOSTED__
 
52
 
 
53
@opindex std
 
54
@opindex ansi
 
55
@opindex pedantic
 
56
@opindex pedantic-errors
 
57
The original ANSI C standard (X3.159-1989) was ratified in 1989 and
 
58
published in 1990.  This standard was ratified as an ISO standard
 
59
(ISO/IEC 9899:1990) later in 1990.  There were no technical
 
60
differences between these publications, although the sections of the
 
61
ANSI standard were renumbered and became clauses in the ISO standard.
 
62
The ANSI
 
63
standard, but not the ISO standard, also came with a Rationale
 
64
document.  
 
65
This standard, in both its forms, is commonly known as @dfn{C89}, or
 
66
occasionally as @dfn{C90}, from the dates of ratification.
 
67
To select this standard in GCC, use one of the options
 
68
@option{-ansi}, @option{-std=c90} or @option{-std=iso9899:1990}; to obtain
 
69
all the diagnostics required by the standard, you should also specify
 
70
@option{-pedantic} (or @option{-pedantic-errors} if you want them to be
 
71
errors rather than warnings).  @xref{C Dialect Options,,Options
 
72
Controlling C Dialect}.
 
73
 
 
74
Errors in the 1990 ISO C standard were corrected in two Technical
 
75
Corrigenda published in 1994 and 1996.  GCC does not support the
 
76
uncorrected version.
 
77
 
 
78
An amendment to the 1990 standard was published in 1995.  This
 
79
amendment added digraphs and @code{__STDC_VERSION__} to the language,
 
80
but otherwise concerned the library.  This amendment is commonly known
 
81
as @dfn{AMD1}; the amended standard is sometimes known as @dfn{C94} or
 
82
@dfn{C95}.  To select this standard in GCC, use the option
 
83
@option{-std=iso9899:199409} (with, as for other standard versions,
 
84
@option{-pedantic} to receive all required diagnostics).
 
85
 
 
86
A new edition of the ISO C standard was published in 1999 as ISO/IEC
 
87
9899:1999, and is commonly known as @dfn{C99}.  (While in
 
88
development, drafts of this standard version were referred to as
 
89
@dfn{C9X}.)  GCC has substantially
 
90
complete support for this standard version; see
 
91
@uref{http://gcc.gnu.org/c99status.html} for details.  To select this
 
92
standard, use @option{-std=c99} or @option{-std=iso9899:1999}.  
 
93
 
 
94
Errors in the 1999 ISO C standard were corrected in three Technical
 
95
Corrigenda published in 2001, 2004 and 2007.  GCC does not support the
 
96
uncorrected version.
 
97
 
 
98
A fourth version of the C standard, known as @dfn{C11}, was published
 
99
in 2011 as ISO/IEC 9899:2011.  (While in development, drafts of this
 
100
standard version were referred to as @dfn{C1X}.)
 
101
GCC has substantially complete support
 
102
for this standard, enabled with @option{-std=c11} or
 
103
@option{-std=iso9899:2011}.  
 
104
 
 
105
By default, GCC provides some extensions to the C language that, on
 
106
rare occasions conflict with the C standard.  @xref{C
 
107
Extensions,,Extensions to the C Language Family}.  
 
108
Some features that are part of the C99 standard
 
109
are accepted as extensions in C90 mode, and some features that are part
 
110
of the C11 standard are accepted as extensions in C90 and C99 modes.
 
111
Use of the
 
112
@option{-std} options listed above disables these extensions where
 
113
they conflict with the C standard version selected.  You may also
 
114
select an extended version of the C language explicitly with
 
115
@option{-std=gnu90} (for C90 with GNU extensions), @option{-std=gnu99}
 
116
(for C99 with GNU extensions) or @option{-std=gnu11} (for C11 with GNU
 
117
extensions).  
 
118
 
 
119
The default, if no C language dialect options are given,
 
120
is @option{-std=gnu11}.  
 
121
 
 
122
The ISO C standard defines (in clause 4) two classes of conforming
 
123
implementation.  A @dfn{conforming hosted implementation} supports the
 
124
whole standard including all the library facilities; a @dfn{conforming
 
125
freestanding implementation} is only required to provide certain
 
126
library facilities: those in @code{<float.h>}, @code{<limits.h>},
 
127
@code{<stdarg.h>}, and @code{<stddef.h>}; since AMD1, also those in
 
128
@code{<iso646.h>}; since C99, also those in @code{<stdbool.h>} and
 
129
@code{<stdint.h>}; and since C11, also those in @code{<stdalign.h>}
 
130
and @code{<stdnoreturn.h>}.  In addition, complex types, added in C99, are not
 
131
required for freestanding implementations.  
 
132
 
 
133
The standard also defines two environments for programs, a
 
134
@dfn{freestanding environment}, required of all implementations and
 
135
which may not have library facilities beyond those required of
 
136
freestanding implementations, where the handling of program startup
 
137
and termination are implementation-defined; and a @dfn{hosted
 
138
environment}, which is not required, in which all the library
 
139
facilities are provided and startup is through a function @code{int
 
140
main (void)} or @code{int main (int, char *[])}.  An OS kernel is an example
 
141
of a program running in a freestanding environment; 
 
142
a program using the facilities of an
 
143
operating system is an example of a program running in a hosted environment.
 
144
 
 
145
@opindex ffreestanding
 
146
GCC aims towards being usable as a conforming freestanding
 
147
implementation, or as the compiler for a conforming hosted
 
148
implementation.  By default, it acts as the compiler for a hosted
 
149
implementation, defining @code{__STDC_HOSTED__} as @code{1} and
 
150
presuming that when the names of ISO C functions are used, they have
 
151
the semantics defined in the standard.  To make it act as a conforming
 
152
freestanding implementation for a freestanding environment, use the
 
153
option @option{-ffreestanding}; it then defines
 
154
@code{__STDC_HOSTED__} to @code{0} and does not make assumptions about the
 
155
meanings of function names from the standard library, with exceptions
 
156
noted below.  To build an OS kernel, you may well still need to make
 
157
your own arrangements for linking and startup.
 
158
@xref{C Dialect Options,,Options Controlling C Dialect}.
 
159
 
 
160
GCC does not provide the library facilities required only of hosted
 
161
implementations, nor yet all the facilities required by C99 of
 
162
freestanding implementations on all platforms.  
 
163
To use the facilities of a hosted
 
164
environment, you need to find them elsewhere (for example, in the
 
165
GNU C library).  @xref{Standard Libraries,,Standard Libraries}.
 
166
 
 
167
Most of the compiler support routines used by GCC are present in
 
168
@file{libgcc}, but there are a few exceptions.  GCC requires the
 
169
freestanding environment provide @code{memcpy}, @code{memmove},
 
170
@code{memset} and @code{memcmp}.
 
171
Finally, if @code{__builtin_trap} is used, and the target does
 
172
not implement the @code{trap} pattern, then GCC emits a call
 
173
to @code{abort}.
 
174
 
 
175
For references to Technical Corrigenda, Rationale documents and
 
176
information concerning the history of C that is available online, see
 
177
@uref{http://gcc.gnu.org/readings.html}
 
178
 
 
179
@section C++ Language
 
180
 
 
181
GCC supports the original ISO C++ standard published in 1998,
 
182
and the 2011 and 2014 revisions.
 
183
 
 
184
The original ISO C++ standard was published as the ISO standard (ISO/IEC
 
185
14882:1998) and amended by a Technical Corrigenda published in 2003
 
186
(ISO/IEC 14882:2003). These standards are referred to as C++98 and
 
187
C++03, respectively. GCC implements the majority of C++98 (@code{export}
 
188
is a notable exception) and most of the changes in C++03.  To select
 
189
this standard in GCC, use one of the options @option{-ansi},
 
190
@option{-std=c++98}, or @option{-std=c++03}; to obtain all the diagnostics
 
191
required by the standard, you should also specify @option{-pedantic} (or
 
192
@option{-pedantic-errors} if you want them to be errors rather than
 
193
warnings).
 
194
 
 
195
A revised ISO C++ standard was published in 2011 as ISO/IEC
 
196
14882:2011, and is referred to as C++11; before its publication it was
 
197
commonly referred to as C++0x.  C++11 contains several changes to the
 
198
C++ language, all of which have been implemented in GCC@. For details
 
199
see @uref{https://gcc.gnu.org/projects/@/cxx0x.html}.
 
200
To select this standard in GCC, use the option @option{-std=c++11}.
 
201
 
 
202
Another revised ISO C++ standard was published in 2014 as ISO/IEC
 
203
14882:2014, and is referred to as C++14; before its publication it was
 
204
sometimes referred to as C++1y.  C++14 contains several further
 
205
changes to the C++ language, all of which have been implemented in GCC@.
 
206
For details see @uref{https://gcc.gnu.org/projects/@/cxx1y.html}.
 
207
To select this standard in GCC, use the option @option{-std=c++14}.
 
208
 
 
209
GCC also supports the C++ Concepts Technical Specification,
 
210
ISO/IEC TS 19217:2015, which allows constraints to be defined for templates,
 
211
allowing template arguments to be checked and for templates to be
 
212
overloaded or specialized based on the constraints. Support for C++ Concepts
 
213
is included in an experimental C++1z mode that corresponds to the next
 
214
revision of the ISO C++ standard, expected to be published in 2017. To enable
 
215
C++1z support in GCC, use the option @option{-std=c++17} or
 
216
@option{-std=c++1z}.
 
217
 
 
218
More information about the C++ standards is available on the ISO C++
 
219
committee's web site at @uref{http://www.open-std.org/@/jtc1/@/sc22/@/wg21/}.
 
220
 
 
221
To obtain all the diagnostics required by any of the standard versions
 
222
described above you should specify @option{-pedantic}
 
223
or @option{-pedantic-errors}, otherwise GCC will allow some non-ISO C++
 
224
features as extensions. @xref{Warning Options}.
 
225
 
 
226
By default, GCC also provides some additional extensions to the C++ language
 
227
that on rare occasions conflict with the C++ standard.  @xref{C++
 
228
Dialect Options,Options Controlling C++ Dialect}.  Use of the
 
229
@option{-std} options listed above disables these extensions where they
 
230
they conflict with the C++ standard version selected.  You may also
 
231
select an extended version of the C++ language explicitly with
 
232
@option{-std=gnu++98} (for C++98 with GNU extensions), or
 
233
@option{-std=gnu++11} (for C++11 with GNU extensions), or
 
234
@option{-std=gnu++14} (for C++14 with GNU extensions), or
 
235
@option{-std=gnu++1z} (for C++1z with GNU extensions).  
 
236
 
 
237
The default, if
 
238
no C++ language dialect options are given, is @option{-std=gnu++14}.
 
239
 
 
240
@section Objective-C and Objective-C++ Languages
 
241
@cindex Objective-C
 
242
@cindex Objective-C++
 
243
 
 
244
GCC supports ``traditional'' Objective-C (also known as ``Objective-C
 
245
1.0'') and contains support for the Objective-C exception and
 
246
synchronization syntax.  It has also support for a number of
 
247
``Objective-C 2.0'' language extensions, including properties, fast
 
248
enumeration (only for Objective-C), method attributes and the
 
249
@@optional and @@required keywords in protocols.  GCC supports
 
250
Objective-C++ and features available in Objective-C are also available
 
251
in Objective-C++@.
 
252
 
 
253
GCC by default uses the GNU Objective-C runtime library, which is part
 
254
of GCC and is not the same as the Apple/NeXT Objective-C runtime
 
255
library used on Apple systems.  There are a number of differences
 
256
documented in this manual.  The options @option{-fgnu-runtime} and
 
257
@option{-fnext-runtime} allow you to switch between producing output
 
258
that works with the GNU Objective-C runtime library and output that
 
259
works with the Apple/NeXT Objective-C runtime library.
 
260
 
 
261
There is no formal written standard for Objective-C or Objective-C++@.
 
262
The authoritative manual on traditional Objective-C (1.0) is
 
263
``Object-Oriented Programming and the Objective-C Language'':
 
264
@itemize
 
265
@item
 
266
@uref{http://www.gnustep.org/@/resources/@/documentation/@/ObjectivCBook.pdf}
 
267
is the original NeXTstep document;
 
268
@item
 
269
@uref{http://objc.toodarkpark.net}
 
270
is the same document in another format.
 
271
@end itemize
 
272
 
 
273
The Objective-C exception and synchronization syntax (that is, the
 
274
keywords @code{@@try}, @code{@@throw}, @code{@@catch},
 
275
@code{@@finally} and @code{@@synchronized}) is
 
276
supported by GCC and is enabled with the option
 
277
@option{-fobjc-exceptions}.  The syntax is briefly documented in this
 
278
manual and in the Objective-C 2.0 manuals from Apple.
 
279
 
 
280
The Objective-C 2.0 language extensions and features are automatically
 
281
enabled; they include properties (via the @code{@@property},
 
282
@code{@@synthesize} and
 
283
@code{@@dynamic keywords}), fast enumeration (not available in
 
284
Objective-C++), attributes for methods (such as @code{deprecated},
 
285
@code{noreturn}, @code{sentinel}, @code{format}),
 
286
the @code{unused} attribute for method arguments, the
 
287
@code{@@package} keyword for instance variables and the @code{@@optional} and
 
288
@code{@@required} keywords in protocols.  You can disable all these
 
289
Objective-C 2.0 language extensions with the option
 
290
@option{-fobjc-std=objc1}, which causes the compiler to recognize the
 
291
same Objective-C language syntax recognized by GCC 4.0, and to produce
 
292
an error if one of the new features is used.
 
293
 
 
294
GCC has currently no support for non-fragile instance variables.
 
295
 
 
296
The authoritative manual on Objective-C 2.0 is available from Apple:
 
297
@itemize
 
298
@item
 
299
@uref{https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html}
 
300
@end itemize
 
301
 
 
302
For more information concerning the history of Objective-C that is
 
303
available online, see @uref{http://gcc.gnu.org/readings.html}
 
304
 
 
305
@section Go Language
 
306
 
 
307
As of the GCC 4.7.1 release, GCC supports the Go 1 language standard,
 
308
described at @uref{http://golang.org/doc/go1.html}.
 
309
 
 
310
@section References for Other Languages
 
311
 
 
312
@xref{Top, GNAT Reference Manual, About This Guide, gnat_rm,
 
313
GNAT Reference Manual}, for information on standard
 
314
conformance and compatibility of the Ada compiler.
 
315
 
 
316
@xref{Standards,,Standards, gfortran, The GNU Fortran Compiler}, for details
 
317
of standards supported by GNU Fortran.
 
318
 
 
319
@xref{Compatibility,,Compatibility with the Java Platform, gcj, GNU gcj},
 
320
for details of compatibility between @command{gcj} and the Java Platform.