Changeset View
Changeset View
Standalone View
Standalone View
share/man/man7/c.7
- This file was moved from share/man/man7/c99.7.
.\" Copyright (C) 2007, 2010 Gabor Kovesdan. All rights reserved. | .\" Copyright (C) 2007, 2010 Gabor Kovesdan. All rights reserved. | ||||
.\" Copyright (C) 2021 Faraz Vahedi <kfv@kfv.io> | |||||
.\" | .\" | ||||
.\" Redistribution and use in source and binary forms, with or without | .\" Redistribution and use in source and binary forms, with or without | ||||
.\" modification, are permitted provided that the following conditions | .\" modification, are permitted provided that the following conditions | ||||
.\" are met: | .\" are met: | ||||
.\" 1. Redistributions of source code must retain the above copyright | .\" 1. Redistributions of source code must retain the above copyright | ||||
.\" notice, this list of conditions and the following disclaimer. | .\" notice, this list of conditions and the following disclaimer. | ||||
.\" 2. Redistributions in binary form must reproduce the above copyright | .\" 2. Redistributions in binary form must reproduce the above copyright | ||||
.\" notice, this list of conditions and the following disclaimer in the | .\" notice, this list of conditions and the following disclaimer in the | ||||
.\" documentation and/or other materials provided with the distribution. | .\" documentation and/or other materials provided with the distribution. | ||||
.\" | .\" | ||||
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND | .\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND | ||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE | .\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE | ||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
.\" SUCH DAMAGE. | .\" SUCH DAMAGE. | ||||
.\" | .\" | ||||
.\" $FreeBSD$ | .\" $FreeBSD$ | ||||
.\" | .\" | ||||
.Dd May 30, 2011 | .Dd April 18, 2021 | ||||
.Dt C 7 | .Dt C 7 | ||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm c , | .Nm c , | ||||
.Nm c78 , | .Nm c78 , | ||||
.Nm c89 , | .Nm c89 , | ||||
.Nm c90 , | .Nm c90 , | ||||
.Nm c99 | .Nm c95 , | ||||
.Nm c99 , | |||||
.Nm c11 , | |||||
.Nm c17 , | |||||
.Nm c2x | |||||
.Nd The C programming language | .Nd The C programming language | ||||
.Sh DESCRIPTION | .Sh DESCRIPTION | ||||
C is a general purpose programming language, which has a strong connection | C is a general purpose programming language, which has a strong connection | ||||
with the UNIX operating system and its derivatives, since the vast | with the UNIX operating system and its derivatives, since the vast | ||||
majority of those systems were written in the C language. | majority of those systems were written in the C language. | ||||
The C language contains some basic ideas from the BCPL language through | The C language contains some basic ideas from the BCPL language through | ||||
the B language written by Ken Thompson in 1970 for the DEC PDP-7 machines. | the B language written by Ken Thompson in 1970 for the DEC PDP-7 machines. | ||||
The development of the UNIX operating system was started on a PDP-7 | The development of the UNIX operating system was started on a PDP-7 | ||||
Show All 33 Lines | |||||
used. | used. | ||||
To not lose the portability by using these system calls, the POSIX | To not lose the portability by using these system calls, the POSIX | ||||
(Portable Operating System Interface) standard evolved. | (Portable Operating System Interface) standard evolved. | ||||
It describes what functions should be available to keep portability. | It describes what functions should be available to keep portability. | ||||
Note, that POSIX is not a C standard, but an operating system standard | Note, that POSIX is not a C standard, but an operating system standard | ||||
and thus is beyond the scope of this manual. | and thus is beyond the scope of this manual. | ||||
The standards discussed below are all C standards and only cover | The standards discussed below are all C standards and only cover | ||||
the C programming language and the accompanying library. | the C programming language and the accompanying library. | ||||
All listed improvements for each standard edition are taken from the official | |||||
bcr: The use of "you" is discouraged in technical documentation. You can remove the sentence parts… | |||||
Done Inline ActionsI will keep it in mind, thanks! kfv_kfv.io: I will keep it in mind, thanks! | |||||
standard drafts. | |||||
For further details, check the publicly available drafts or | |||||
purchase the published standards \(em from either ISO or IEC resources. | |||||
.Pp | .Pp | ||||
After the publication of the book mentioned before, | After the publication of the book mentioned before, | ||||
the American National Standards Institute (ANSI) started to work on | the American National Standards Institute (ANSI) started to work on | ||||
standardizing the language, and they announced ANSI X3.159-1989 | standardizing the language, and they announced ANSI X3.159-1989 | ||||
in 1989. | in 1989. | ||||
It is usually referred as ANSI C or C89. | It is usually referred to as ANSI C or C89. | ||||
The main difference in this standard were the function prototypes, | The main difference in this standard were the function prototypes, | ||||
which is a new way of declaring functions. | which is a new way of declaring functions. | ||||
With the old-style function declarations, the compiler was unable to | With the old-style function declarations, the compiler was unable to | ||||
check the sanity of the actual parameters at a function call. | check the sanity of the actual parameters at a function call. | ||||
The old syntax was highly error-prone because incompatible parameters | The old syntax was highly error-prone because incompatible parameters | ||||
were hard to detect in the program code and the problem only showed up | were hard to detect in the program code and the problem only showed up | ||||
at run-time. | at run-time. | ||||
.Pp | .Pp | ||||
In 1990, the International Organization for Standardization (ISO) adopted | In 1990, the International Organization for Standardization (ISO) adopted | ||||
the ANSI standard as ISO/IEC 9899:1990 in 1990. | the ANSI standard as ISO/IEC 9899:1990 in 1990. | ||||
This is also referred as ISO C or C90. | This is also referred to as ISO C or C90. | ||||
It only contains negligible minor modifications against ANSI C, | It only contains negligible minor modifications against ANSI C, | ||||
so the two standards often considered to be fully equivalent. | so the two standards often considered to be fully equivalent. | ||||
This was a very important milestone in the history of the C language, but the | This was a very important milestone in the history of the C language, but the | ||||
development of the language did not stop. | development of the language did not stop. | ||||
.Pp | .Pp | ||||
The ISO C standard was later extended with an amendment as | The ISO C standard was later extended with an amendment as | ||||
ISO/IEC 9899 AM1 in 1995. | ISO/IEC 9899/AMD1 in 1995. | ||||
This contained, for example, the wide-character support in wchar.h and | This contained, for example, the wide-character support in <wchar.h> and | ||||
wctype.h. | <wctype.h>, and also restricted character set support via diagraphs and | ||||
Two corrigenda were also published: Technical Corrigendum 1 as | <iso646.h>. | ||||
ISO/IEC 9899 TCOR1 in 1995 and Technical Corrigendum 2 as ISO/IEC 9899 TCOR1 | This amendment is usually referred to as C95. | ||||
Two technical corrigenda were also published: Technical Corrigendum 1 as | |||||
ISO/IEC 9899/COR1 in 1994 and Technical Corrigendum 2 as ISO/IEC 9899/COR2 | |||||
in 1996. | in 1996. | ||||
The continuous development and growth made it necessary to work out a new | The continuous development and growth made it necessary to work out a new | ||||
standard, which contains the new features and fixes the known defects and | standard, which contains the new features and fixes the known defects and | ||||
deficiencies of the language. | deficiencies of the language. | ||||
As a result, ISO/IEC 9899:1999 was born in 1999. | As a result, ISO/IEC 9899:1999 was born in 1999 as the second edition of the | ||||
Similarly to the other standards, this is referred after the | standard. | ||||
Similarly to the other standards, this is informally named after the | |||||
publication year as C99. | publication year as C99. | ||||
The improvements include the following: | The improvements include (but are not limited to) the following: | ||||
.Bl -bullet -offset indent | .Bl -bullet -offset indent | ||||
.It | .It | ||||
Inline functions | digraphs, trigraphs, and alternative spellings for the operators that | ||||
use non-ISO646 characters in <iso646.h> | |||||
.It | .It | ||||
Support for variable length arrays | extended multibyte and wide character library support in <wchar.h> and | ||||
<wctype.h> | |||||
.It | .It | ||||
New high-precision integer type named long long int, and other integer types | variable length arrays | ||||
defined in stdint.h | |||||
.It | .It | ||||
New boolean data type implemented in stdbool.h | flexible array members | ||||
.It | .It | ||||
One line comments taken from the C++ language | complex (and imaginary) number arithmetic support in <complex.h> | ||||
.It | .It | ||||
Some new preprocessor features | type-generic math macros in <tgmath.h> | ||||
.It | .It | ||||
New variables can be declared anywhere, not just in the beginning of the | the long long int type and library functions | ||||
program or program blocks | |||||
.It | .It | ||||
No implicit int type | remove implicit int type | ||||
.It | |||||
universal character names (\eu and \eU) | |||||
.It | |||||
compound literals | |||||
.It | |||||
remove implicit function declaration | |||||
.It | |||||
BCPL style single-line comments | |||||
.It | |||||
allow mixed declarations and code | |||||
.It | |||||
the vscanf family of functions in <stdio.h> and <wchar.h> | |||||
.It | |||||
allow trailing comma in enum declaration | |||||
.It | |||||
inline functions | |||||
.It | |||||
the snprintf family of functions in <stdio.h> | |||||
.It | |||||
boolean type and macros in <stdbool.h> | |||||
.It | |||||
empty macro arguments | |||||
.It | |||||
_Pragma preprocessing operator | |||||
.It | |||||
__func__ predefined identifier | |||||
.It | |||||
va_copy macro in <stdarg.h> | |||||
.It | |||||
additional strftime conversion specifiers | |||||
.El | .El | ||||
.Pp | .Pp | ||||
Since then new standards have not been published, but the C language is still | Later in 2011, the third edition of the standard, ISO/IEC 1989:2011, | ||||
evolving. | commonly reffered to as C11 (formerly C1x), came out and replaced the | ||||
New and useful features have been showed up in the most famous | second edition by ISO/IEC 9899:1999/COR1:2001, ISO/IEC 9899:1999/COR2:2004, | ||||
C compiler: GNU C. | and ISO/IEC 9899:1999/COR3:2007. | ||||
Most of the UNIX-like operating systems use GNU C as a system compiler, | The improvements include (but are not limited to) the following: | ||||
but those addition in GNU C should not be considered as | .Bl -bullet -offset indent | ||||
standard features. | .It | ||||
support for multiple threads of execution and atomic operations in <threads.h> | |||||
and <stdatomic.h> | |||||
.It | |||||
additional floating-point characteristic macros in <float.h> | |||||
.It | |||||
querying and specifying alignment of objects in <stdalign.h> and <stdlib.h> | |||||
.It | |||||
Unicode character types and functions in <uchar.h> | |||||
.It | |||||
type-generic expressions | |||||
.It | |||||
static assertions in <assert.h> | |||||
.It | |||||
anonymous structures and unions | |||||
.It | |||||
remove the gets function from <stdio.h> | |||||
.It | |||||
add the aligned_alloc, at_quick_exit, and quick_exit functions in <stdlib.h> | |||||
.El | |||||
.Pp | |||||
C11 was later superseded by ISO/IEC 9899:2018, also known as C17 which was | |||||
prepared in 2017 and published in June 2018 as the fourth edition. | |||||
It incorporates the Technical Corrigendum 1 (ISO/IEC 9899:2011/COR1:2012) | |||||
which was published in 2012. | |||||
It addressed defects and deficiencies in C11 without introducing new features, | |||||
only corrections and clarifications. | |||||
Since there were no major changes in C17, the current standrad for | |||||
Programming Language C, is still considered C11 \(em ISO/IEC 9899:2011, published | |||||
2011-12-08. | |||||
Done Inline Actionss/Porgramming/Programming juan.molina_club.fr: s/Porgramming/Programming | |||||
Done Inline ActionsThanks! kfv_kfv.io: Thanks! | |||||
.Pp | |||||
The next standard, the fifth, is currently referred to as C2x and is scheduled | |||||
to be adopted by the end of 2021, with a publication date of 2022. | |||||
When published, it will cancel and replace the fourth edition, ISO/IEC | |||||
9899:2018. | |||||
.Pp | |||||
Some useful features have been provided as extensions by some compilers, but | |||||
they cannot be considered as standard features. | |||||
Done Inline ActionsYou can remove the "you should" here. bcr: You can remove the "you should" here. | |||||
.Pp | |||||
ISO/IEC JTC1/SC22/WG14 committee is responsible for the ISO/IEC 9899, | |||||
C Standard. | |||||
.Sh SEE ALSO | .Sh SEE ALSO | ||||
.Xr c89 1 , | .Xr c89 1 , | ||||
.Xr c99 1 , | .Xr c99 1 , | ||||
.Xr cc 1 | .Xr cc 1 | ||||
.Sh STANDARDS | .Sh STANDARDS | ||||
.Rs | .Rs | ||||
.%A ANSI | .%A ANSI | ||||
.%T X3.159-1989 | .%T X3.159-1989 (aka C89 or ANSI C) | ||||
.Re | .Re | ||||
.Pp | .Pp | ||||
.Rs | .Rs | ||||
.%A ISO/IEC | .%A ISO/IEC | ||||
.%T 9899:1990, Programming languages -- C | .%T 9899:1990 (aka C90) | ||||
.Re | .Re | ||||
.Pp | .Pp | ||||
.Rs | .Rs | ||||
.%A ISO/IEC | .%A ISO/IEC | ||||
.%T 9899 AM1 | .%T 9899:1990/AMD 1:1995, Amendment 1: C Integrity (aka C95) | ||||
.Re | .Re | ||||
.Pp | .Pp | ||||
.Rs | .Rs | ||||
.%A ISO/IEC | .%A ISO/IEC | ||||
.%T 9899 TCOR1, Programming languages -- C, Technical Corrigendum 1 | .%T 9899:1990/COR 1:1994, Technical Corrigendum 1 | ||||
.Re | .Re | ||||
.Pp | .Pp | ||||
.Rs | .Rs | ||||
.%A ISO/IEC | .%A ISO/IEC | ||||
.%T 9899 TCOR2, Programming languages -- C, Technical Corrigendum 2 | .%T 9899:1990/COR 2:1996, Technical Corrigendum 2 | ||||
.Re | .Re | ||||
.Pp | .Pp | ||||
.Rs | .Rs | ||||
.%A ISO/IEC | .%A ISO/IEC | ||||
.%T 9899:1999, Programming languages -- C | .%T 9899:1999 (aka C99) | ||||
.Re | .Re | ||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T 9899:1999/COR 1:2001, Technical Corrigendum 1 | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T 9899:1999/COR 2:2004, Technical Corrigendum 2 | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T 9899:1999/COR 3:2007, Technical Corrigendum 3 | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TR 24731-1:2007 (aka bounds-checking interfaces) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TS 18037:2008 (aka, embedded C) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TR 24747:2009 (aka mathematical special functions) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TR 24732:2009 (aka decimal floating-point) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TR 24731-2:2010 (aka dynamic allocation functions) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T 9899:2011 (aka C11) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T 9899:2011/COR 1:2012, Technical Corrigendum 1 | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TS 17961:2013 (aka C secure coding rules) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TS 18861-1:2014 (aka binary floating-point) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TS 18861-2:2015 (aka decimal floating-point) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TS 18861-3:2015 (aka interchange and extended types) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TS 18861-4:2015 (aka supplementary functions) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TS 17961:2013/COR 1:2016 (aka C secure coding rules TC1) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T TS 18861-5:2016 (aka supplementary attributes) | |||||
.Re | |||||
.Pp | |||||
.Rs | |||||
.%A ISO/IEC | |||||
.%T 9899:2018 (aka C17) | |||||
.Re | |||||
.Sh HISTORY | .Sh HISTORY | ||||
This manual page first appeared in | This manual page first appeared in | ||||
.Fx 9.0 . | .Fx 9.0 . | ||||
.Sh AUTHORS | .Sh AUTHORS | ||||
.An -nosplit | |||||
This manual page was originally written by | This manual page was originally written by | ||||
.An Gabor Kovesdan Aq Mt gabor@FreeBSD.org . | .An Gabor Kovesdan Aq Mt gabor@FreeBSD.org . | ||||
It was updated for | |||||
.Fx 14.0 | |||||
by | |||||
.An Faraz Vahedi Aq Mt kfv@kfv.io | |||||
with information about more recent C standards. |
The use of "you" is discouraged in technical documentation. You can remove the sentence parts "you can" here to fix it.