* doc/standards.texi: Mention C99 TC1.
[gcc.git] / gcc / doc / standards.texi
1 @c Copyright (C) 2000, 2001 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 @cindex C standard
8 @cindex C standards
9 @cindex ANSI C standard
10 @cindex ANSI C
11 @cindex ANSI C89
12 @cindex C89
13 @cindex ANSI X3.159-1989
14 @cindex X3.159-1989
15 @cindex ISO C standard
16 @cindex ISO C
17 @cindex ISO C89
18 @cindex ISO C90
19 @cindex ISO/IEC 9899
20 @cindex ISO 9899
21 @cindex C90
22 @cindex ISO C94
23 @cindex C94
24 @cindex ISO C95
25 @cindex C95
26 @cindex ISO C99
27 @cindex C99
28 @cindex ISO C9X
29 @cindex C9X
30 @cindex Technical Corrigenda
31 @cindex TC1
32 @cindex Technical Corrigendum 1
33 @cindex TC2
34 @cindex Technical Corrigendum 2
35 @cindex AMD1
36 @cindex freestanding implementation
37 @cindex freestanding environment
38 @cindex hosted implementation
39 @cindex hosted environment
40 @findex __STDC_HOSTED__
41
42 For each language compiled by GCC for which there is a standard, GCC
43 attempts to follow one or more versions of that standard, possibly
44 with some exceptions, and possibly with some extensions.
45
46 GCC supports three versions of the C standard, although support for
47 the most recent version is not yet complete.
48
49 @opindex std
50 @opindex ansi
51 @opindex pedantic
52 @opindex pedantic-errors
53 The original ANSI C standard (X3.159-1989) was ratified in 1989 and
54 published in 1990. This standard was ratified as an ISO standard
55 (ISO/IEC 9899:1990) later in 1990. There were no technical
56 differences between these publications, although the sections of the
57 ANSI standard were renumbered and became clauses in the ISO standard.
58 This standard, in both its forms, is commonly known as @dfn{C89}, or
59 occasionally as @dfn{C90}, from the dates of ratification. The ANSI
60 standard, but not the ISO standard, also came with a Rationale
61 document. To select this standard in GCC, use one of the options
62 @option{-ansi}, @option{-std=c89} or @option{-std=iso9899:1990}; to obtain
63 all the diagnostics required by the standard, you should also specify
64 @option{-pedantic} (or @option{-pedantic-errors} if you want them to be
65 errors rather than warnings). @xref{C Dialect Options,,Options
66 Controlling C Dialect}.
67
68 Errors in the 1990 ISO C standard were corrected in two Technical
69 Corrigenda published in 1994 and 1996. GCC does not support the
70 uncorrected version.
71
72 An amendment to the 1990 standard was published in 1995. This
73 amendment added digraphs and @code{__STDC_VERSION__} to the language,
74 but otherwise concerned the library. This amendment is commonly known
75 as @dfn{AMD1}; the amended standard is sometimes known as @dfn{C94} or
76 @dfn{C95}. To select this standard in GCC, use the option
77 @option{-std=iso9899:199409} (with, as for other standard versions,
78 @option{-pedantic} to receive all required diagnostics).
79
80 A new edition of the ISO C standard was published in 1999 as ISO/IEC
81 9899:1999, and is commonly known as @dfn{C99}. GCC has incomplete
82 support for this standard version; see
83 @uref{http://gcc.gnu.org/c99status.html} for details. To select this
84 standard, use @option{-std=c99} or @option{-std=iso9899:1999}. (While in
85 development, drafts of this standard version were referred to as
86 @dfn{C9X}.)
87
88 Errors in the 1999 ISO C standard were corrected in a Technical
89 Corrigendum published in 2001. GCC does not support the uncorrected
90 version.
91
92 @opindex traditional
93 GCC also has some limited support for traditional (pre-ISO) C with the
94 @option{-traditional} option. This support may be of use for compiling
95 some very old programs that have not been updated to ISO C, but should
96 not be used for new programs. It will not work with some modern C
97 libraries such as the GNU C library.
98
99 By default, GCC provides some extensions to the C language that on
100 rare occasions conflict with the C standard. @xref{C
101 Extensions,,Extensions to the C Language Family}. Use of the
102 @option{-std} options listed above will disable these extensions where
103 they conflict with the C standard version selected. You may also
104 select an extended version of the C language explicitly with
105 @option{-std=gnu89} (for C89 with GNU extensions) or @option{-std=gnu99}
106 (for C99 with GNU extensions). The default, if no C language dialect
107 options are given, is @option{-std=gnu89}; this will change to
108 @option{-std=gnu99} in some future release when the C99 support is
109 complete. Some features that are part of the C99 standard are
110 accepted as extensions in C89 mode.
111
112 The ISO C standard defines (in clause 4) two classes of conforming
113 implementation. A @dfn{conforming hosted implementation} supports the
114 whole standard including all the library facilities; a @dfn{conforming
115 freestanding implementation} is only required to provide certain
116 library facilities: those in @code{<float.h>}, @code{<limits.h>},
117 @code{<stdarg.h>}, and @code{<stddef.h>}; since AMD1, also those in
118 @code{<iso646.h>}; and in C99, also those in @code{<stdbool.h>} and
119 @code{<stdint.h>}. In addition, complex types, added in C99, are not
120 required for freestanding implementations. The standard also defines
121 two environments for programs, a @dfn{freestanding environment},
122 required of all implementations and which may not have library
123 facilities beyond those required of freestanding implementations,
124 where the handling of program startup and termination are
125 implementation-defined, and a @dfn{hosted environment}, which is not
126 required, in which all the library facilities are provided and startup
127 is through a function @code{int main (void)} or @code{int main (int,
128 char *[])}. An OS kernel would be a freestanding environment; a
129 program using the facilities of an operating system would normally be
130 in a hosted implementation.
131
132 @opindex ffreestanding
133 GCC aims towards being usable as a conforming freestanding
134 implementation, or as the compiler for a conforming hosted
135 implementation. By default, it will act as the compiler for a hosted
136 implementation, defining @code{__STDC_HOSTED__} as @code{1} and
137 presuming that when the names of ISO C functions are used, they have
138 the semantics defined in the standard. To make it act as a conforming
139 freestanding implementation for a freestanding environment, use the
140 option @option{-ffreestanding}; it will then define
141 @code{__STDC_HOSTED__} to @code{0} and not make assumptions about the
142 meanings of function names from the standard library. To build an OS
143 kernel, you may well still need to make your own arrangements for
144 linking and startup. @xref{C Dialect Options,,Options Controlling C
145 Dialect}.
146
147 GCC does not provide the library facilities required only of hosted
148 implementations, nor yet all the facilities required by C99 of
149 freestanding implementations; to use the facilities of a hosted
150 environment, you will need to find them elsewhere (for example, in the
151 GNU C library). @xref{Standard Libraries,,Standard Libraries}.
152
153 For references to Technical Corrigenda, Rationale documents and
154 information concerning the history of C that is available online, see
155 @uref{http://gcc.gnu.org/readings.html}
156
157 @c FIXME: details of C++ standard.
158
159 There is no formal written standard for Objective-C@. The most
160 authoritative manual is ``Object-Oriented Programming and the
161 Objective-C Language'', available at a number of web sites;
162 @uref{http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/} has a
163 recent version, while @uref{http://www.toodarkpark.org/computers/objc/}
164 is an older example. @uref{http://www.gnustep.org} includes useful
165 information as well.
166
167 @xref{Top, GNAT Reference Manual, About This Guide, gnat_rm,
168 GNAT Reference Manual}, for information on standard
169 conformance and compatibility of the Ada compiler.
170
171 @xref{References,,Language Definition References, chill, GNU Chill},
172 for details of the CHILL standard.
173
174 @xref{Language,,The GNU Fortran Language, g77, Using and Porting GNU
175 Fortran}, for details of the Fortran language supported by GCC@.
176
177 @xref{Compatibility,,Compatibility with the Java Platform, gcj, GNU gcj},
178 for details of compatibility between @code{gcj} and the Java Platform.