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