annotate gcc/doc/standards.texi @ 145:1830386684a0

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