]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man7/c.7
zfs: merge openzfs/zfs@75b4cbf62 (master) into main
[FreeBSD/FreeBSD.git] / share / man / man7 / c.7
1 .\" Copyright (C) 2007, 2010 Gabor Kovesdan. All rights reserved.
2 .\" Copyright (C) 2021 Faraz Vahedi <kfv@kfv.io>
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd April 20, 2021
28 .Dt C 7
29 .Os
30 .Sh NAME
31 .Nm c ,
32 .Nm c78 ,
33 .Nm c89 ,
34 .Nm c90 ,
35 .Nm c95 ,
36 .Nm c99 ,
37 .Nm c11 ,
38 .Nm c17 ,
39 .Nm c2x
40 .Nd The C programming language
41 .Sh DESCRIPTION
42 C is a general purpose programming language, which has a strong connection
43 with the UNIX operating system and its derivatives, since the vast
44 majority of those systems were written in the C language.
45 The C language contains some basic ideas from the BCPL language through
46 the B language written by Ken Thompson in 1970 for the DEC PDP-7 machines.
47 The development of the UNIX operating system was started on a PDP-7
48 machine in assembly language, but it made very difficult to port the existing
49 code to other systems.
50 .Pp
51 In 1972 Dennis M. Ritchie worked out the C programming language for
52 further development of the UNIX operating system.
53 The idea was to implement only the C compiler for different
54 platforms, and implement most part of the operating system
55 in the new programming language to simplify the portability between
56 different architectures.
57 It follows that C is very eligible for (but not limited to) writing
58 operating systems and low-level applications.
59 .Pp
60 The C language did not have a specification or standardized version for
61 a long time.
62 It went through a lot of changes and improvements for ages.
63 In 1978, Brian W. Kernighan and Dennis M. Ritchie published the
64 first book about C under the title "The C Programming Language".
65 We can think of this book as the first specification of the language.
66 This version is often referred as K&R C after the names of the authors.
67 Sometimes it is referred as C78, as well, after the publishing year of
68 the first edition of the book.
69 .Pp
70 It is important to notice, that the instruction set of the language is
71 limited to the most fundamental elements for simplicity.
72 Handling of the standard I/O and such common functions are implemented in
73 the libraries shipped with the compiler.
74 As these functions are also widely used, it was demanded to include into
75 the description what requisites the library should conform to, not just
76 strictly the language itself.
77 Accordingly, the aforementioned standards cover the library elements, as well.
78 The elements of this standard library is still not enough for more
79 complicated tasks.
80 In this case the provided system calls of the given operating system can be
81 used.
82 To not lose the portability by using these system calls, the POSIX
83 (Portable Operating System Interface) standard evolved.
84 It describes what functions should be available to keep portability.
85 Note, that POSIX is not a C standard, but an operating system standard
86 and thus is beyond the scope of this manual.
87 The standards discussed below are all C standards and only cover
88 the C programming language and the accompanying library.
89 All listed improvements for each standard edition are taken from the official
90 standard drafts.
91 For further details, check the publicly available drafts or
92 purchase the published standards \(em from either ISO or IEC resources.
93 .Pp
94 After the publication of the book mentioned before,
95 the American National Standards Institute (ANSI) started to work on
96 standardizing the language, and they announced ANSI X3.159-1989
97 in 1989.
98 It is usually referred to as ANSI C or C89.
99 The main difference in this standard were the function prototypes,
100 which is a new way of declaring functions.
101 With the old-style function declarations, the compiler was unable to
102 check the sanity of the actual parameters at a function call.
103 The old syntax was highly error-prone because incompatible parameters
104 were hard to detect in the program code and the problem only showed up
105 at run-time.
106 .Pp
107 In 1990, the International Organization for Standardization (ISO) adopted
108 the ANSI standard as ISO/IEC 9899:1990 in 1990.
109 This is also referred to as ISO C or C90.
110 It only contains negligible minor modifications against ANSI C,
111 so the two standards often considered to be fully equivalent.
112 This was a very important milestone in the history of the C language, but the
113 development of the language did not stop.
114 .Pp
115 The ISO C standard was later extended with an amendment as
116 ISO/IEC 9899/AMD1 in 1995.
117 This contained, for example, the wide-character support in <wchar.h> and
118 <wctype.h>, and also restricted character set support via diagraphs and
119 <iso646.h>.
120 This amendment is usually referred to as C95.
121 Two technical corrigenda were also published: Technical Corrigendum 1 as
122 ISO/IEC 9899/COR1 in 1994 and Technical Corrigendum 2 as ISO/IEC 9899/COR2
123 in 1996.
124 The continuous development and growth made it necessary to work out a new
125 standard, which contains the new features and fixes the known defects and
126 deficiencies of the language.
127 As a result, ISO/IEC 9899:1999 was born in 1999 as the second edition of the
128 standard.
129 Similarly to the other standards, this is informally named after the
130 publication year as C99.
131 The improvements include (but are not limited to) the following:
132 .Bl -bullet -offset indent
133 .It
134 digraphs, trigraphs, and alternative spellings for the operators that
135 use non-ISO646 characters in <iso646.h>
136 .It
137 extended multibyte and wide character library support in <wchar.h> and
138 <wctype.h>
139 .It
140 variable length arrays
141 .It
142 flexible array members
143 .It
144 complex (and imaginary) number arithmetic support in <complex.h>
145 .It
146 type-generic math macros in <tgmath.h>
147 .It
148 the long long int type and library functions
149 .It
150 remove implicit int type
151 .It
152 universal character names (\eu and \eU)
153 .It
154 compound literals
155 .It
156 remove implicit function declaration
157 .It
158 BCPL style single-line comments
159 .It
160 allow mixed declarations and code
161 .It
162 the vscanf family of functions in <stdio.h> and <wchar.h>
163 .It
164 allow trailing comma in enum declaration
165 .It
166 inline functions
167 .It
168 the snprintf family of functions in <stdio.h>
169 .It
170 boolean type and macros in <stdbool.h>
171 .It
172 empty macro arguments
173 .It
174 _Pragma preprocessing operator
175 .It
176 __func__ predefined identifier
177 .It
178 va_copy macro in <stdarg.h>
179 .It
180 additional strftime conversion specifiers
181 .El
182 .Pp
183 Later in 2011, the third edition of the standard, ISO/IEC 1989:2011,
184 commonly referred to as C11 (formerly C1x), came out and replaced the
185 second edition by ISO/IEC 9899:1999/COR1:2001, ISO/IEC 9899:1999/COR2:2004,
186 and ISO/IEC 9899:1999/COR3:2007.
187 The improvements include (but are not limited to) the following:
188 .Bl -bullet -offset indent
189 .It
190 support for multiple threads of execution and atomic operations in <threads.h>
191 and <stdatomic.h>
192 .It
193 additional floating-point characteristic macros in <float.h>
194 .It
195 querying and specifying alignment of objects in <stdalign.h> and <stdlib.h>
196 .It
197 Unicode character types and functions in <uchar.h>
198 .It
199 type-generic expressions
200 .It
201 static assertions in <assert.h>
202 .It
203 anonymous structures and unions
204 .It
205 remove the gets function from <stdio.h>
206 .It
207 add the aligned_alloc, at_quick_exit, and quick_exit functions in <stdlib.h>
208 .El
209 .Pp
210 C11 was later superseded by ISO/IEC 9899:2018, also known as C17 which was
211 prepared in 2017 and published in June 2018 as the fourth edition.
212 It incorporates the Technical Corrigendum 1 (ISO/IEC 9899:2011/COR1:2012)
213 which was published in 2012.
214 It addressed defects and deficiencies in C11 without introducing new features,
215 only corrections and clarifications.
216 Since there were no major changes in C17, the current standard for
217 Programming Language C, is still considered C11 \(em ISO/IEC 9899:2011, published
218 2011-12-08.
219 .Pp
220 The next standard, the fifth, is currently referred to as C2x and is scheduled
221 to be adopted by the end of 2021, with a publication date of 2022.
222 When published, it will cancel and replace the fourth edition, ISO/IEC
223 9899:2018.
224 .Pp
225 Some useful features have been provided as extensions by some compilers, but
226 they cannot be considered as standard features.
227 .Pp
228 ISO/IEC JTC1/SC22/WG14 committee is responsible for the ISO/IEC 9899,
229 C Standard.
230 .Sh SEE ALSO
231 .Xr c89 1 ,
232 .Xr c99 1 ,
233 .Xr cc 1
234 .Sh STANDARDS
235 .Rs
236 .%A ANSI
237 .%T X3.159-1989 (aka C89 or ANSI C)
238 .Re
239 .Pp
240 .Rs
241 .%A ISO/IEC
242 .%T 9899:1990 (aka C90)
243 .Re
244 .Pp
245 .Rs
246 .%A ISO/IEC
247 .%T 9899:1990/AMD 1:1995, Amendment 1: C Integrity (aka C95)
248 .Re
249 .Pp
250 .Rs
251 .%A ISO/IEC
252 .%T 9899:1990/COR 1:1994, Technical Corrigendum 1
253 .Re
254 .Pp
255 .Rs
256 .%A ISO/IEC
257 .%T 9899:1990/COR 2:1996, Technical Corrigendum 2
258 .Re
259 .Pp
260 .Rs
261 .%A ISO/IEC
262 .%T 9899:1999 (aka C99)
263 .Re
264 .Pp
265 .Rs
266 .%A ISO/IEC
267 .%T 9899:1999/COR 1:2001, Technical Corrigendum 1
268 .Re
269 .Pp
270 .Rs
271 .%A ISO/IEC
272 .%T 9899:1999/COR 2:2004, Technical Corrigendum 2
273 .Re
274 .Pp
275 .Rs
276 .%A ISO/IEC
277 .%T 9899:1999/COR 3:2007, Technical Corrigendum 3
278 .Re
279 .Pp
280 .Rs
281 .%A ISO/IEC
282 .%T TR 24731-1:2007 (aka bounds-checking interfaces)
283 .Re
284 .Pp
285 .Rs
286 .%A ISO/IEC
287 .%T TS 18037:2008 (aka, embedded C)
288 .Re
289 .Pp
290 .Rs
291 .%A ISO/IEC
292 .%T TR 24747:2009 (aka mathematical special functions)
293 .Re
294 .Pp
295 .Rs
296 .%A ISO/IEC
297 .%T TR 24732:2009 (aka decimal floating-point)
298 .Re
299 .Pp
300 .Rs
301 .%A ISO/IEC
302 .%T TR 24731-2:2010 (aka dynamic allocation functions)
303 .Re
304 .Pp
305 .Rs
306 .%A ISO/IEC
307 .%T 9899:2011 (aka C11)
308 .Re
309 .Pp
310 .Rs
311 .%A ISO/IEC
312 .%T 9899:2011/COR 1:2012, Technical Corrigendum 1
313 .Re
314 .Pp
315 .Rs
316 .%A ISO/IEC
317 .%T TS 17961:2013 (aka C secure coding rules)
318 .Re
319 .Pp
320 .Rs
321 .%A ISO/IEC
322 .%T TS 18861-1:2014 (aka binary floating-point)
323 .Re
324 .Pp
325 .Rs
326 .%A ISO/IEC
327 .%T TS 18861-2:2015 (aka decimal floating-point)
328 .Re
329 .Pp
330 .Rs
331 .%A ISO/IEC
332 .%T TS 18861-3:2015 (aka interchange and extended types)
333 .Re
334 .Pp
335 .Rs
336 .%A ISO/IEC
337 .%T TS 18861-4:2015 (aka supplementary functions)
338 .Re
339 .Pp
340 .Rs
341 .%A ISO/IEC
342 .%T TS 17961:2013/COR 1:2016 (aka C secure coding rules TC1)
343 .Re
344 .Pp
345 .Rs
346 .%A ISO/IEC
347 .%T TS 18861-5:2016 (aka supplementary attributes)
348 .Re
349 .Pp
350 .Rs
351 .%A ISO/IEC
352 .%T 9899:2018 (aka C17)
353 .Re
354 .Sh HISTORY
355 This manual page first appeared in
356 .Fx 9.0 .
357 .Sh AUTHORS
358 .An -nosplit
359 This manual page was originally written by
360 .An Gabor Kovesdan Aq Mt gabor@FreeBSD.org .
361 It was updated for
362 .Fx 14.0
363 by
364 .An Faraz Vahedi Aq Mt kfv@kfv.io
365 with information about more recent C standards.