xref: /netbsd-src/share/man/man7/c.7 (revision 23ee83f7c0aea0777bd89d8ebd7f0cde9880d13c)
1.\" $NetBSD: c.7,v 1.15 2023/08/27 15:50:47 rillig Exp $
2.\"
3.\" Copyright (C) 2007, 2010 Gabor Kovesdan. All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD: src/share/man/man7/c99.7,v 1.1 2010/06/17 12:05:47 gabor Exp $
27.\"
28.Dd March 30, 2011
29.Dt C 7
30.Os
31.Sh NAME
32.Nm c, c78, c89, c90, c99, c11
33.Nd The C programming language
34.Sh DESCRIPTION
35C is a general-purpose programming language, which has a strong connection
36with the UNIX operating system and its derivatives, since the vast
37majority of those systems were written in the C language.
38The C language contains some basic ideas from the BCPL language through
39the B language written by Ken Thompson in 1970 for the DEC PDP-7 machines.
40The development of the UNIX operating system was started on a PDP-7
41machine in assembly language, but this choice made it very difficult
42to port the existing code to other systems.
43.Pp
44In 1972, Dennis M. Ritchie worked out the C programming language for
45further development of the UNIX operating system.
46The idea was to implement only the C compiler for different
47platforms, and implement most parts of the operating system
48in the new programming language to simplify the portability between
49different architectures.
50It follows that C is very well adapted for (but not limited to) writing
51operating systems and low-level applications.
52.Pp
53The C language did not have a specification or standardized version for
54a long time.
55It went through a lot of changes and improvements for ages.
56In 1978, Brian W. Kernighan and Dennis M. Ritchie published the
57first book about C under the title
58.Dq The C Programming Language .
59We can think of this book as the first specification of the language.
60This version is often referred to as
61.Dq K&R C
62after the names of the authors.
63Sometimes it is referred to as C78, as well, after the publishing year of
64the first edition of the book.
65.Pp
66It is important to notice that the instruction set of the language is
67limited to the most fundamental elements for simplicity.
68Handling of the standard I/O and similar common functions are implemented in
69the libraries shipped with the compiler.
70As these functions are also widely used, it was demanded to include into
71the description what requisites the library should conform to, not just
72strictly the language itself.
73Accordingly, the aforementioned standards cover the library elements, as well.
74The elements of this standard library are still not enough for more
75complicated tasks.
76In this case the provided system calls of the given operating system can be
77used.
78To not lose the portability by using these system calls, the POSIX
79(Portable Operating System Interface (for Unix)) standard evolved.
80It describes what functions should be available to keep portability.
81Note that POSIX is not a C standard, but an operating system standard
82and thus is beyond the scope of this manual.
83The standards discussed below are all C standards and only cover
84the C programming language and the accompanying library.
85.Pp
86After the publication of the book mentioned before,
87the American National Standards Institute (ANSI) started to work on
88standardizing the language, and in 1989 they announced ANSI X3.159-1989.
89It is usually referred to as ANSI C or C89.
90The main difference in this standard were the function prototypes,
91which was a new way of declaring functions.
92With the old-style function declarations, the compiler was unable to
93check the sanity of the actual parameters of a function call.
94The old syntax was highly error-prone because incompatible parameters
95were hard to detect in the program code and the problem only showed up
96at run-time.
97.Pp
98In 1990, the International Organization for Standardization (ISO) adopted
99the ANSI standard as ISO/IEC 9899:1990.
100This is also referred to as ISO C or C90.
101It only contains negligible minor modifications against ANSI C,
102so the two standards are often considered to be fully equivalent.
103This was a very important milestone in the history of the C language, but the
104development of the language did not stop.
105.Pp
106The ISO C standard was later extended with an amendment as
107ISO/IEC 9899 AM1 in 1995.
108This contained, for example, the wide-character support in
109.In wchar.h
110and
111.In wctype.h .
112Two corrigenda were also published:
113Technical Corrigendum 1 as ISO/IEC 9899 TCOR1 in 1995,
114and Technical Corrigendum 2 as ISO/IEC 9899 TCOR2 in 1996.
115The continuous development and growth made it necessary to work out a new
116standard, which contains the new features and fixes the known defects and
117deficiencies of the language.
118As a result, ISO/IEC 9899:1999 was born in 1999.
119Similarly to the other standards, this is referred to after the
120publication year as C99.
121The improvements include the following:
122.Bl -bullet -offset indent
123.It
124Inline functions.
125.It
126Support for variable length arrays.
127.It
128New large-range integer type named
129.Vt long long int ,
130and other integer types described in
131.Xr stdint 3
132and
133.Xr inttypes 3 .
134.It
135New boolean data type; see
136.Xr stdbool 3 .
137.It
138One-line comments taken from the C++ language.
139.It
140Some new preprocessor features.
141.It
142A predefined identifier
143.Va __func__
144and a
145.Vt restrict
146type qualifier.
147.It
148Declarations are allowed after statements, not just in the beginning of the
149program or program blocks.
150.It
151No implicit
152.Vt int
153type.
154.El
155.Pp
156In 2011, another revision of ISO/IEC 9899 was published, nicknamed C11,
157adding features such as:
158.Bl -bullet -offset indent
159.It
160Compile-time assertions.
161.It
162Type-generic expressions.
163.It
164Unnamed struct and union members.
165.El
166.Pp
167In 2017, another revision of ISO/IEC 9899 was published, nicknamed C17,
168containing corrections to C11, but no new features.
169.Pp
170Since then no new standards have been published, but the C language is still
171evolving.
172.Pp
173Most of the UNIX-like operating systems use GNU C as a system compiler,
174but the various extensions of GNU C, such as
175.Xr attribute 3
176or
177.Xr typeof 3 ,
178should not be considered standard features.
179.Sh SEE ALSO
180.Xr c89 1 ,
181.Xr c99 1 ,
182.Xr c11 1 ,
183.Xr cc 1 ,
184.Xr cdefs 3
185.Rs
186.%A Brian W. Kernighan
187.%A Dennis M. Ritchie
188.%B The C Programming Language
189.%D 1988
190.%N Second Edition, 40th printing
191.%I Prentice Hall
192.Re
193.Sh STANDARDS
194.Rs
195.%A ANSI
196.%T X3.159-1989
197.Re
198.Pp
199.Rs
200.%A ISO/IEC
201.%T 9899:1990, Programming languages -- C
202.Re
203.Pp
204.Rs
205.%A ISO/IEC
206.%T 9899 AM1
207.Re
208.Pp
209.Rs
210.%A ISO/IEC
211.%T 9899 TCOR1, Programming languages -- C, Technical Corrigendum 1
212.Re
213.Pp
214.Rs
215.%A ISO/IEC
216.%T 9899 TCOR2, Programming languages -- C, Technical Corrigendum 2
217.Re
218.Pp
219.Rs
220.%A ISO/IEC
221.%T 9899:1999, Programming languages -- C
222.Re
223.Pp
224.Rs
225.%A ISO/IEC
226.%T 9899:1999 TCOR1, Programming languages -- C, Technical Corrigendum 1
227.Re
228.Pp
229.Rs
230.%A ISO/IEC
231.%T 9899:1999 TCOR2, Programming languages -- C, Technical Corrigendum 2
232.Re
233.Pp
234.Rs
235.%A ISO/IEC
236.%T 9899:1999 TCOR3, Programming languages -- C, Technical Corrigendum 3
237.Re
238.Pp
239.Rs
240.%A ISO/IEC
241.%T 9899:2011, Programming languages -- C
242.Re
243.Sh HISTORY
244This manual page first appeared in
245.Fx 9.0
246and
247.Nx 6.0 .
248.Sh AUTHORS
249This manual page was written by
250.An Gabor Kovesdan Aq Mt gabor@FreeBSD.org .
251