xref: /netbsd/share/man/man7/c.7 (revision 6550d01e)
1.\" $NetBSD: c.7,v 1.11 2011/01/19 00:06:22 uwe 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 December 17, 2010
29.Dt C 7
30.Os
31.Sh NAME
32.Nm c, c78, c89, c90, c99
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 wchar.h and
109wctype.h.
110Two corrigenda were also published: Technical Corrigendum 1 as
111ISO/IEC 9899 TCOR1 in 1995 and Technical Corrigendum 2 as ISO/IEC 9899 TCOR2
112in 1996.
113The continuous development and growth made it necessary to work out a new
114standard, which contains the new features and fixes the known defects and
115deficiencies of the language.
116As a result, ISO/IEC 9899:1999 was born in 1999.
117Similarly to the other standards, this is referred to after the
118publication year as C99.
119The improvements include the following:
120.Bl -bullet -offset indent
121.It
122Inline functions.
123.It
124Support for variable length arrays.
125.It
126New high-precision integer type named
127.Vt long long int ,
128and other integer types described in
129.Xr stdint 3
130and
131.Xr inttypes 3 .
132.It
133New boolean data type; see
134.Xr stdbool 3 .
135.It
136One line comments taken from the C++ language.
137.It
138Some new preprocessor features.
139.It
140A predefined identifier
141.Va __func__
142and a
143.Vt restrict
144type qualifier.
145.It
146New variables can be declared anywhere, not just in the beginning of the
147program or program blocks.
148.It
149No implicit
150.Vt int
151type.
152.El
153.Pp
154Since then no new standards have been published, but the C language is still
155evolving.
156New and useful features have been showing up in the most famous
157C compiler: GNU C
158.Pq Xr gcc 1 .
159Most of the UNIX-like operating systems use GNU C as a system compiler,
160but the various extensions of GNU C, such as
161.Xr attribute 3
162or
163.Xr typeof 3 ,
164should not be considered standard features.
165.Sh SEE ALSO
166.Xr c89 1 ,
167.Xr c99 1 ,
168.Xr cc 1
169.Rs
170.%A Brian W. Kernighan
171.%A Dennis M. Ritchie
172.%B The C Programming Language
173.%D 1988
174.%N Second Edition, 40th printing
175.%I Prentice Hall
176.Re
177.Sh STANDARDS
178.Rs
179.%A ANSI
180.%T X3.159-1989
181.Re
182.Pp
183.Rs
184.%A ISO/IEC
185.%T 9899:1990, Programming languages -- C
186.Re
187.Pp
188.Rs
189.%A ISO/IEC
190.%T 9899 AM1
191.Re
192.Pp
193.Rs
194.%A ISO/IEC
195.%T 9899 TCOR1, Programming languages -- C, Technical Corrigendum 1
196.Re
197.Pp
198.Rs
199.%A ISO/IEC
200.%T 9899 TCOR2, Programming languages -- C, Technical Corrigendum 2
201.Re
202.Pp
203.Rs
204.%A ISO/IEC
205.%T 9899:1999, Programming languages -- C
206.Re
207.Pp
208.Rs
209.%A ISO/IEC
210.%T 9899:1999 TCOR1, Programming languages -- C, Technical Corrigendum 1
211.Re
212.Pp
213.Rs
214.%A ISO/IEC
215.%T 9899:1999 TCOR2, Programming languages -- C, Technical Corrigendum 2
216.Re
217.Pp
218.Rs
219.%A ISO/IEC
220.%T 9899:1999 TCOR3, Programming languages -- C, Technical Corrigendum 3
221.Re
222.Sh HISTORY
223This manual page first appeared in
224.Fx 9.0
225and
226.Nx 6.0 .
227.Sh AUTHORS
228This manual page was written by
229.An Gabor Kovesdan Aq gabor@FreeBSD.org .
230