Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
C (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== History == === Early developments === {| class="wikitable floatright" style="margin-left: 1.5em;" |+Timeline of C language |- ! Year ! Informal<br />name ! Official<br />standard |- | 1972 | first release | {{N/A}} |- | 1978 | [[K&R C]] | {{N/A}} |- | 1989,<br />1990 | [[ANSI C]], C89,<br />ISO C, C90 | ANSI X3.159-1989<br />ISO/IEC 9899:1990 |- | 1999 | [[C99]], C9X | ISO/IEC 9899:1999 |- | 2011 | [[C11 (C standard revision)|C11]], C1X | ISO/IEC 9899:2011 |- | 2018 | [[C17 (C standard revision)|C17]], C18 | ISO/IEC 9899:2018 |- | 2024 | [[C23 (C standard revision)|C23]], C2X | ISO/IEC 9899:2024 |- | {{TBA}} | [[#C2Y|C2Y]] | |} The origin of C is closely tied to the development of the [[Unix]] operating system, originally implemented in [[assembly language]] on a [[PDP-7]] by [[Dennis Ritchie]] and [[Ken Thompson]], incorporating several ideas from colleagues. Eventually, they decided to port the operating system to a [[PDP-11]]. The original PDP-11 version of Unix was also developed in assembly language.<ref name="sigplan" /> ==== B ==== {{main|B (programming language)}} Thompson wanted a programming language for developing utilities for the new platform. He first tried writing a [[Fortran]] compiler, but he soon gave up the idea and instead created a cut-down version of the recently developed [[systems programming language]] called [[BCPL]]. The official description of BCPL was not available at the time,<ref name="NFDsZ">{{cite web |url=https://www.lysator.liu.se/c/dmr-on-histories.html |first=Dennis |last=Ritchie |title=BCPL to B to C |website=lysator.liu.se |access-date=September 10, 2019 |archive-date=December 12, 2019 |archive-url=https://web.archive.org/web/20191212221532/http://www.lysator.liu.se/c/dmr-on-histories.html |url-status=live }}</ref> and Thompson modified the syntax to be less 'wordy' and similar to a simplified [[ALGOL]] known as SMALGOL.<ref name="Ars">{{Cite web |last=Jensen |first=Richard |date=December 9, 2020 |title="A damn stupid thing to do"βthe origins of C |url=https://arstechnica.com/features/2020/12/a-damn-stupid-thing-to-do-the-origins-of-c/ |access-date=March 28, 2022 |website=Ars Technica |language=en-us |archive-date=March 28, 2022 |archive-url=https://web.archive.org/web/20220328143845/https://arstechnica.com/features/2020/12/a-damn-stupid-thing-to-do-the-origins-of-c/ |url-status=live }}</ref> He called the result [[B (programming language)|''B'']],<ref name="sigplan" /> describing it as "BCPL semantics with a lot of SMALGOL syntax".<ref name=Ars /> Like BCPL, B had a [[bootstrapping]] compiler to facilitate porting to new machines.<ref name=Ars /> Ultimately, few utilities were written in B because it was too slow and could not take advantage of PDP-11 features such as [[byte]] addressability. ==== New B and first C release ==== In 1971 Ritchie started to improve B, to use the features of the more-powerful PDP-11. A significant addition was a character data type. He called this ''New B'' (NB).<ref name=Ars /> Thompson started to use NB to write the [[Research Unix|Unix]] kernel, and his requirements shaped the direction of the language development.<ref name="Ars" /><ref name="unixport" /> Through to 1972, richer types were added to the NB language: NB had arrays of <code>int</code> and <code>char</code>. Pointers, the ability to generate pointers to other types, arrays of all types, and types to be returned from functions were all also added. Arrays within expressions became pointers. A new compiler was written, and the language was renamed C.<ref name=sigplan /> The C compiler and some utilities made with it were included in [[Version 2 Unix]], which is also known as [[Research Unix]].<ref name="QtqTh">{{cite tech report |first=M. D. |last=McIlroy |author-link=Doug McIlroy |year=1987 |url=http://www.cs.dartmouth.edu/~doug/reader.pdf |title=A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971β1986 |series=CSTR |number=139 |institution=Bell Labs |format=PDF |page=10 |access-date=February 1, 2015 |archive-date=November 11, 2017 |archive-url=https://web.archive.org/web/20171111151817/http://www.cs.dartmouth.edu/~doug/reader.pdf |url-status=live }}</ref> ==== Structures and Unix kernel re-write ==== At [[Version 4 Unix]], released in November 1973, the [[Unix]] [[kernel (operating system)|kernel]] was extensively re-implemented in C.<ref name="sigplan" /> By this time, the C language had acquired some powerful features such as <code>struct</code> types. The [[C preprocessor|preprocessor]] was introduced around 1973 at the urging of [[Alan Snyder (computer scientist)|Alan Snyder]] and also in recognition of the usefulness of the file-inclusion mechanisms available in BCPL and [[PL/I]]. Its original version provided only included files and simple string replacements: <code>#include</code> and <code>#define</code> of parameterless macros. Soon after that, it was extended, mostly by [[Mike Lesk]] and then by John Reiser, to incorporate macros with arguments and [[conditional compilation]].<ref name="sigplan">{{harvtxt|Ritchie|1993}}</ref> Unix was one of the first operating system kernels implemented in a language other than [[assembly language|assembly]]. Earlier instances include the [[Multics]] system (which was written in [[PL/I]]) and [[Master Control Program]] (MCP) for the [[Burroughs large systems|Burroughs B5000]] (which was written in [[ALGOL]]) in 1961. In around <!--Better?: {{Circa|1977}}--> 1977, Ritchie and [[Stephen C. Johnson]] made further changes to the language to facilitate [[Software portability|portability]] of the Unix operating system. Johnson's [[Portable C Compiler]] served as the basis for several implementations of C on new platforms.<ref name="unixport">{{cite journal |last1=Johnson |first1=S. C. |author-link1=Stephen C. Johnson |last2=Ritchie |first2=D. M. |author-link2=Dennis Ritchie |title=Portability of C Programs and the UNIX System |journal=Bell System Tech. J. |year=1978 |volume=57 |issue=6 |pages=2021β2048 |doi=10.1002/j.1538-7305.1978.tb02141.x |citeseerx=10.1.1.138.35 |s2cid=17510065 |issn = 0005-8580 }} (Note: The PDF is an OCR scan of the original, and contains a rendering of "IBM 370" as "IBM 310".)</ref> === K&R C ===<!--[[K&R C]] redirects here--> [[File:The C Programming Language, First Edition Cover (2).svg|thumb|240x240px|The cover of the book ''The C Programming Language'', first edition, by [[Brian Kernighan]] and [[Dennis Ritchie]]]] In 1978 [[Brian Kernighan]] and [[Dennis Ritchie]] published the first edition of ''[[The C Programming Language]]''.<ref name="k&r1e">{{cite book |last1=Kernighan |first1=Brian W. |author-link1=Brian Kernighan |last2=Ritchie |first2=Dennis M. |author-link2=Dennis Ritchie | title=The C Programming Language | edition=1st |publisher=[[Prentice Hall]] |date=February 1978 |location=[[Englewood Cliffs, NJ]] |isbn=978-0-13-110163-0|title-link=The C Programming Language}}</ref> Known as ''K&R'' from the initials of its authors, the book served for many years as an informal [[Specification (technical standard)|specification]] of the language. The version of C that it describes is commonly referred to as "'''K&R C'''<!--boldface per WP:R#PLA-->". As this was released in 1978, it is now also referred to as ''C78''.<ref name="qOvzA">{{cite book |url=https://nxmnpg.lemoda.net/7/c78 |title=FreeBSD Miscellaneous Information Manual |date=May 30, 2011 |edition=FreeBSD 13.0 |chapter=C manual pages |access-date=January 15, 2021 |archive-url=https://web.archive.org/web/20210121024455/https://nxmnpg.lemoda.net/7/c78 |archive-date=January 21, 2021 |url-status=live}} [https://www.freebsd.org/cgi/man.cgi?query=c78&apropos=0&sektion=0&manpath=FreeBSD+9-current&arch=default&format=html] {{Webarchive|url=https://web.archive.org/web/20210121033654/https://www.freebsd.org/cgi/man.cgi?query=c78&apropos=0&sektion=0&manpath=FreeBSD+9-current&arch=default&format=html|date=January 21, 2021}}</ref> The second edition of the book<ref name="k&r2e">{{cite book |last1=Kernighan |first1=Brian W. |author-link1=Brian Kernighan |last2=Ritchie |first2=Dennis M. |author-link2=Dennis Ritchie |title=The C Programming Language | edition=2nd |publisher=[[Prentice Hall]] |date=March 1988 |location=[[Englewood Cliffs, NJ]] |isbn=978-0-13-110362-7|title-link=The C Programming Language |ref=none}}</ref> covers the later [[ANSI C]] standard, described below. ''K&R'' introduced several language features: * [[C file input/output|Standard I/O library]] * <code>[[long int]]</code> data type * <code>unsigned int</code> data type * Compound assignment operators of the form <code>=''op''</code> (such as <code>=-</code>) were changed to the form <code>''op''=</code> (that is, <code>-=</code>) to remove the semantic ambiguity created by constructs such as <code>i=-10</code>, which had been interpreted as <code>i =- 10</code> (decrement <code>i</code> by 10) instead of the possibly intended <code>i = -10</code> (let <code>i</code> be β10). Even after the publication of the 1989 ANSI standard, for many years K&R C was still considered the "[[Lowest common denominator (computers)|lowest common denominator]]" to which C programmers restricted themselves when maximum portability was desired, since many older compilers were still in use, and because carefully written K&R C code can be legal Standard C as well. In early versions of C, only functions that return types other than <code>int</code> must be declared if used before the function definition; functions used without prior declaration were presumed to return type <code>int</code>. For example: <syntaxhighlight lang="c"> long some_function(); /* This is a function declaration, so the compiler can know the name and return type of this function. */ /* int */ other_function(); /* Another function declaration. Because this is an early version of C, there is an implicit 'int' type here. A comment shows where the explicit 'int' type specifier would be required in later versions. */ /* int */ calling_function() /* This is a function definition, including the body of the code following in the { curly brackets }. Because no return type is specified, the function implicitly returns an 'int' in this early version of C. */ { long test1; register /* int */ test2; /* Again, note that 'int' is not required here. The 'int' type specifier */ /* in the comment would be required in later versions of C. */ /* The 'register' keyword indicates to the compiler that this variable should */ /* ideally be stored in a register as opposed to within the stack frame. */ test1 = some_function(); if (test1 > 1) test2 = 0; else test2 = other_function(); return test2; } </syntaxhighlight> The <code>int</code> type specifiers which are commented out could be omitted in K&R C, but are required in later standards. Since K&R function declarations did not include any information about function arguments, function parameter [[Type checking|type checks]] were not performed, although some compilers would issue a warning message if a local function was called with the wrong number of arguments, or if different calls to an external function used different numbers or types of arguments. Separate tools such as Unix's [[Lint programming tool|lint]] utility were developed that (among other things) could check for consistency of function use across multiple source files. In the years following the publication of K&R C, several features were added to the language, supported by compilers from AT&T (in particular [[Portable C Compiler|PCC]]<ref name="SkKfZ">{{cite report |first1=Bjarne |last1=Stroustrup |author-link=Bjarne Stroustrup |title=Sibling rivalry: C and C++ |publisher=AT&T Labs |number=TD-54MQZY |year=2002 |url=http://stroustrup.com/sibling_rivalry.pdf |access-date=April 14, 2014 |archive-date=August 24, 2014 |archive-url=https://web.archive.org/web/20140824072719/http://www.stroustrup.com/sibling_rivalry.pdf |url-status=live }}</ref>) and some other vendors. These included: * <code>[[void type|void]]</code> functions (i.e., functions with no return value) * functions returning <code>[[Struct (C programming language)|struct]]</code> or <code>[[Union (computer science)|union]]</code> types (previously only a single pointer, integer or float could be returned) * [[Assignment (computer science)|assignment]] for <code>struct</code> data types * [[enumerated type]]s (previously, preprocessor definitions for integer fixed values were used, e.g. <code>#define GREEN 3</code>) The large number of extensions and lack of agreement on a [[C standard library|standard library]], together with the language popularity and the fact that not even the Unix compilers precisely implemented the K&R specification, led to the necessity of standardization.<ref>{{Cite web |url=https://www.cs.man.ac.uk/~pjj/cs211/c_rationale/node2.html |title=Rationale for American National Standard for Information Systems β Programming Language β C |access-date=July 17, 2024 |archive-url=https://web.archive.org/web/20240717164722/https://www.cs.man.ac.uk/~pjj/cs211/c_rationale/node2.html |archive-date=July 17, 2024}}</ref> === ANSI C and ISO C === {{Main|ANSI C}} <!-- [[WP:NFCC]] violation: [[File:The C Programming Language cover.svg|thumb|240x240px|The cover of the book, ''[[The C Programming Language]]'', second edition by [[Brian Kernighan]] and [[Dennis Ritchie]] covering ANSI C]] --> During the late 1970s and 1980s, versions of C were implemented for a wide variety of [[mainframe computer]]s, [[minicomputer]]s, and [[microcomputer]]s, including the [[IBM PC]], as its popularity began to increase significantly. In 1983 the [[American National Standards Institute]] (ANSI) formed a committee, X3J11, to establish a standard specification of C. X3J11 based the C standard on the Unix implementation; however, the non-portable portion of the Unix C library was handed off to the [[IEEE]] [[working group]] 1003 to become the basis for the 1988 [[POSIX]] standard. In 1989, the C standard was ratified as ANSI X3.159-1989 "Programming Language C". This version of the language is often referred to as [[ANSI C]], Standard C, or sometimes '''C89'''. In 1990 the ANSI C standard (with formatting changes) was adopted by the [[International Organization for Standardization]] (ISO) as ISO/IEC 9899:1990, which is sometimes called '''C90'''. Therefore, the terms "C89" and "C90" refer to the same programming language. ANSI, like other national standards bodies, no longer develops the C standard independently, but defers to the international C standard, maintained by the working group [[ISO/IEC JTC1/SC22]]/WG14. National adoption of an update to the international standard typically occurs within a year of ISO publication. One of the aims of the C standardization process was to produce a [[superset]] of K&R C, incorporating many of the subsequently introduced unofficial features. The standards committee also included several additional features such as [[function prototype]]s (borrowed from C++), <code>void</code> pointers, support for international [[character sets]] and [[Locale (computer software)|locales]], and preprocessor enhancements. Although the [[C syntax|syntax]] for parameter declarations was augmented to include the style used in C++, the K&R interface continued to be permitted, for compatibility with existing source code. C89 is supported by current C compilers, and most modern C code is based on it. Any program written only in Standard C and without any hardware-dependent assumptions will run correctly on any [[Computing platform|platform]] with a conforming C implementation, within its resource limits. Without such precautions, programs may compile only on a certain platform or with a particular compiler, due, for example, to the use of non-standard libraries, such as [[GUI]] libraries, or to a reliance on compiler- or platform-specific attributes such as the exact size of data types and byte [[endianness]]. In cases where code must be compilable by either standard-conforming or K&R C-based compilers, the <code>__STDC__</code> macro can be used to split the code into Standard and K&R sections to prevent the use on a K&R C-based compiler of features available only in Standard C. After the ANSI/ISO standardization process, the C language specification remained relatively static for several years. In 1995, Normative Amendment 1 to the 1990 C standard (ISO/IEC 9899/AMD1:1995, known informally as C95) was published, to correct some details and to add more extensive support for international character sets.<ref name="NWUon">{{cite book |author=<!--Staff writer(s); no by-line.--> |title=C Integrity |url=https://www.iso.org/standard/23909.html |publisher=International Organization for Standardization |date=March 30, 1995 |access-date=July 24, 2018 |archive-date=July 25, 2018 |archive-url=https://web.archive.org/web/20180725033429/https://www.iso.org/standard/23909.html |url-status=live }}</ref> === C99 === {{Main|C99}} The C standard was further revised in the late 1990s, leading to the publication of ISO/IEC 9899:1999 in 1999, which is commonly referred to as "[[C99]]". It has since been amended three times by Technical Corrigenda.<ref name="WG14">{{cite web |title=JTC1/SC22/WG14 β C |url=http://www.open-std.org/jtc1/sc22/wg14/ |work=Home page |publisher=ISO/IEC |access-date=June 2, 2011 |archive-date=February 12, 2018 |archive-url=https://web.archive.org/web/20180212100115/http://www.open-std.org/JTC1/SC22/WG14/ |url-status=live }}</ref> C99 introduced several new features, including [[inline function]]s, several new [[data type]]s (including <code>long long int</code> and a <code>complex</code> type to represent [[complex number]]s), [[variable-length array]]s and [[flexible array member]]s, improved support for [[IEEE 754]] floating point, support for [[variadic macro]]s (macros of variable [[arity]]), and support for one-line comments beginning with <code>//</code>, as in BCPL or C++. Many of these had already been implemented as extensions in several C compilers. C99 is for the most part backward compatible with C90, but is stricter in some ways; in particular, a declaration that lacks a type specifier no longer has <code>int</code> implicitly assumed. A standard macro <code>__STDC_VERSION__</code> is defined with value <code>199901L</code> to indicate that C99 support is available. [[GNU Compiler Collection|GCC]], [[Solaris Studio]], and other C compilers now{{when|date=August 2022}} support many or all of the new features of C99. The C compiler in [[Microsoft Visual C++]], however, implements the C89 standard and those parts of C99 that are required for compatibility with [[C++11]].<ref name="YTKIv">{{cite web |url=http://www.drdobbs.com/cpp/interview-with-herb-sutter/231900562 |title=Interview with Herb Sutter |website=[[Dr. Dobbs]] |author=Andrew Binstock |date=October 12, 2011 |access-date=September 7, 2013 |archive-date=August 2, 2013 |archive-url=https://web.archive.org/web/20130802070446/http://www.drdobbs.com/cpp/interview-with-herb-sutter/231900562 |url-status=live }}</ref>{{update inline|date=February 2021}} In addition, the C99 standard requires support for [[Identifier (computer languages)|identifiers]] using [[Unicode]] in the form of escaped characters (e.g. {{code|\u0040}} or {{code|\U0001f431}}) and suggests support for raw Unicode names. === C11 === {{Main|C11 (C standard revision)}} Work began in 2007 on another revision of the C standard, informally called "C1X" until its official publication of ISO/IEC 9899:2011 on December 8, 2011. The C standards committee adopted guidelines to limit the adoption of new features that had not been tested by existing implementations. The C11 standard adds numerous new features to C and the library, including type generic macros, anonymous structures, improved Unicode support, atomic operations, multi-threading, and bounds-checked functions. It also makes some portions of the existing C99 library optional, and improves compatibility with C++. The standard macro <code>__STDC_VERSION__</code> is defined as <code>201112L</code> to indicate that C11 support is available. === C17 === {{Main|C17 (C standard revision)}} C17 is an informal name for ISO/IEC 9899:2018, a standard for the C programming language published in June 2018. It introduces no new language features, only technical corrections, and clarifications to defects in C11. The standard macro <code>__STDC_VERSION__</code> is defined as <code>201710L</code> to indicate that C17 support is available. === C23 === {{Main|C23 (C standard revision)}} C23 is an informal name for the current major C language standard revision. It was informally known as "C2X" through most of its development. C23 was published in October 2024 as ISO/IEC 9899:2024.<ref name="N3132">{{cite web |title=WG14-N3132 : Revised C23 Schedule |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3132.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20230609204739/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3132.pdf |archive-date=June 9, 2023 |date=June 4, 2023 |url-status=live}}</ref> The standard macro <code>__STDC_VERSION__</code> is defined as <code>202311L</code> to indicate that C23 support is available. === C2Y === C2Y is an informal name for the next major C language standard revision, after C23 (C2X), that is hoped to be released later in the 2020s, hence the '2' in "C2Y". An early working draft of C2Y was released in February 2024 as N3220 by the working group [[ISO/IEC JTC1/SC22]]/WG14.<ref name="N3220">{{cite web |title=WG14-N3220 : Working Draft, C2y |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20240226053735/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf |archive-date=February 26, 2024 |date=February 21, 2024 |url-status=live}}</ref> === Embedded C === {{Main|Embedded C}} Historically, embedded C programming requires non-standard extensions to the C language to support exotic features such as [[fixed-point arithmetic]], multiple distinct [[memory bank]]s, and basic I/O operations. In 2008, the C Standards Committee published a [[technical report]] extending the C language<ref name="TR18037">{{cite web |title=TR 18037: Embedded C |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf |website=open-std.org |id=ISO/IEC JTC1 SC22 WG14 N1169 |date=April 4, 2006 |access-date=July 26, 2011 |archive-date=February 25, 2021 |archive-url=https://web.archive.org/web/20210225224616/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf |url-status=live }}</ref> to address these issues by providing a common standard for all implementations to adhere to. It includes a number of features not available in normal C, such as fixed-point arithmetic, named address spaces, and basic I/O hardware addressing.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)