Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
ANSI C
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
{{Short description|Standards for the C programming language}} {{About|the programming language standard|the paper size|Paper size#ANSI paper sizes}} {{C language revisions}} '''ANSI C''', '''ISO C''', and '''Standard C''' are successive standards for the [[C (programming language)|C programming language]] published by the [[American National Standards Institute]] (ANSI) and [[ISO/IEC JTC 1/SC 22]]/WG 14 of the [[International Organization for Standardization]] (ISO) and the [[International Electrotechnical Commission]] (IEC). Historically, the names referred specifically to the original and best-supported version of the standard (known as '''C89''' or '''C90'''). Software developers writing in C are encouraged to conform to the standards, as doing so helps [[porting|portability]] between compilers. ==History and outlook== The first standard for C was published by ANSI. Although this document was subsequently adopted by ISO/IEC and subsequent revisions published by ISO/IEC have been adopted by ANSI, "ANSI C" is still used to refer to the standard.<ref>{{cite web|url=https://blog.ansi.org/2017/09/origin-ansi-c-iso-c/|title=The Origin of ANSI C and ISO C|author=Brad Kelechava|access-date=2018-08-14|date=2017-09-14}}</ref> While some software developers use the term ISO C, others are standards-body neutral and use Standard C. === Informal specification: K&R C (''C78'') === {{Main article|K&R C}} Informal [[Specification (technical standard)|specification]] in 1978 ([[Brian Kernighan]] and [[Dennis Ritchie]] book ''[[The C Programming Language]]''). ===Standardizing C=== In 1983, the American National Standards Institute formed a committee, X3J11, to establish a standard specification of C. In 1985, the first Standard Draft was released, sometimes referred to as ''C85''. In 1986, another Draft Standard was released, sometimes referred to as ''C86''. The prerelease Standard C was published in 1988, and sometimes referred to as ''C88''.<ref name=PCMag-198809-pp116p117>{{cite magazine |publication-date=13 September 1988 |volume= 7 |number= 15 |magazine= PC Magazine |pages=116β117 |title= Standard C: The ANSI Draft Grows Up |author= Richard Hale Shaw |url=https://archive.org/details/PC-Mag-1988-09-13/page/n115/ |access-date=15 November 2022}}</ref> ===C89=== The ANSI standard was completed in 1989 and ratified as ANSI X3.159-1989 "Programming Language C." This version of the language is often referred to as "ANSI C". Later on sometimes the label "C89" is used to distinguish it from C90 but using the same labeling method. ===C90=== The same standard as C89 was ratified by ISO/IEC as ISO/IEC 9899:1990, with only formatting changes,<ref>{{cite web|url=https://gcc.gnu.org/onlinedocs/gcc/Standards.html|title=Standards - Using the GNU Compiler Collection (GCC)|access-date=2012-06-24}}</ref> which is sometimes referred to as C90. Therefore, the terms "C89" and "C90" refer to a language that is virtually identical. This standard has been withdrawn by both ANSI/INCITS<ref name="ref1">{{Cite web|url=http://www.techstreet.com/cgi-bin/detail?doc_no=incits_iso_iec%7C9899;product_id=232462|title=INCITS/ISO/IEC 9899|website=www.techstreet.com|language=en|access-date=2018-10-03}}</ref> and ISO/IEC.<ref>{{cite web|url=http://www.iso.org/iso/iso_catalogue/catalogue_ics/catalogue_detail_ics.htm?csnumber=17782|title=ISO/IEC 9899:1990 - Programming Languages -- C|access-date=2012-06-24}}</ref> ===C95=== In 1995, the [[International Organization for Standardization|ISO]]/[[International Electrotechnical Commission|IEC]] published an extension, called Amendment 1, for the C standard. Its full name finally was ''ISO/IEC 9899:1990/AMD1:1995'' or nicknamed ''C95''. Aside from error correction there were further changes to the language capabilities,<ref>{{Cite web| url=http://www.lysator.liu.se/c/na1.html | title=A brief description of Normative Addendum 1 | author=Clive D.W. Feather | date=2010-09-12}}</ref><ref>{{Cite web|url=https://www.iso.org/standard/23909.html|title=ISO/IEC 9899:1990/Amd 1:1995|date=2013-03-22|publisher=International Organization for Standardization}}</ref> such as: * Improved ''multi-byte'' and ''[[wide character]]'' support in the standard library, introducing <code><wchar.h></code> and <code><wctype.h></code> as well as [[Multi-byte character set|multi-byte]] [[Input/output|I/O]] * Addition of [[Digraph (computing)#C|digraphs]] to the language * Specification of standard macros for the alternative specification of operators, e.g. <code>and</code> for <code>&&</code> * Specification of the standard macro <code>__STDC_VERSION__</code> In addition to the amendment, two technical corrigenda were published by ISO for C90: * ISO/IEC 9899:1990/Cor 1:1994 TCOR1 in 1994<ref>{{Cite web|url=http://www.iso.org/cms/render/live/en/sites/isoorg/contents/data/standard/02/42/24271.html|title=ISO/IEC 9899:1990/Cor 1:1994|website=ISO|language=en|access-date=2019-01-21}}</ref> * ISO/IEC 9899:1990/Cor 2:1996 in 1996<ref>{{Cite web|url=http://www.iso.org/cms/render/live/en/sites/isoorg/contents/data/standard/02/71/27110.html|title=ISO/IEC 9899:1990/Cor 2:1996|website=ISO|language=en|access-date=2019-01-21}}</ref> ====Preprocessor test for C95 compatibility==== <syntaxhighlight lang="c"> #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199409L /* C95 compatible source code. */ #elif defined(__STDC__) /* C89 compatible source code. */ #endif </syntaxhighlight> ===C99=== {{Main article|C99}} In March 2000, ANSI adopted the ISO/IEC 9899:1999 standard.<ref>{{Cite web|url=http://www.iso.org/cms/render/live/en/sites/isoorg/contents/data/standard/02/92/29237.html|title=ISO/IEC 9899:1999|website=ISO|language=en|access-date=2019-01-21}}</ref> This standard is commonly referred to as C99. Some notable additions to the previous standard include: * New built-in [[C data types|data types]]: <code>long long</code>, <code>_Bool</code>, <code>_Complex</code>, and <code>_Imaginary</code> * Several new core language features, including static array indices, designated initializers, compound literals, [[variable-length array]]s, [[flexible array member]]s, [[variadic macro]]s, and <code>[[restrict]]</code> keyword * Several new library headers, including <code>[[stdint.h]]</code>, <code><tgmath.h></code>, <code>fenv.h</code>, <code><complex.h></code> * Improved compatibility with several [[C++]] features, including [[inline function]]s, single-line [[Comment (computer programming)|comments]] with <code>//</code>, mixing [[Declaration (computer programming)|declarations]] and code, and universal character names in [[Identifier (computer programming)|identifiers]] * Removed several dangerous C89 language features such as implicit function declarations and implicit <code>int</code> Three technical corrigenda were published by ISO for C99: * ISO/IEC 9899:1999/Cor 1:2001(E) * ISO/IEC 9899:1999/Cor 2:2004(E) * ISO/IEC 9899:1999/Cor 3:2007(E), notable for deprecating the standard library function [[gets()|gets]] This standard has been withdrawn by both ANSI/INCITS<ref>{{cite web|url=https://webstore.ansi.org/Standards/INCITS/INCITSISOIEC98992012|title=INCITS/ISO/IEC 9899-2012|publisher=ANSI}}</ref> and ISO/IEC<ref>{{cite web|url=https://www.iso.org/standard/29237.html|title=ISO/IEC 9899:1999 - Programming Languages -- C|access-date=2012-06-24}}</ref> in favour of C11. ===C11=== {{Main article|C11 (C standard revision)|l1=C11}} C11 was officially ratified and published on December 8, 2011. Notable features include improved [[Unicode]] support, type-generic expressions using the new <code>_Generic</code> keyword, a cross-platform [[thread (computing)|multi-threading]] API (<code>threads.h</code>), and [[linearizability|atomic]] types support in both core language and the library (<code>stdatomic.h</code>). One technical corrigendum has been published by ISO for C11: * ISO/IEC 9899:2011/Cor 1:2012<ref>{{cite web|url=https://www.iso.org/standard/61717.html|title=ISO/IEC 9899:2011/Cor 1:2012|publisher=International Organization for Standardization}}</ref> ===C17=== {{Main article|C17 (C standard revision)|l1=C17}} C17 was published in June 2018.<ref name="ISO2018">{{cite web|url=https://www.iso.org/standard/74528.html|title=ISO/IEC 9899:2018 - Information technology -- Programming languages -- C|website=www.iso.org}}</ref> Rather than introducing new language features, it only addresses defects in C11.<ref name="iso-9899info">{{cite web|title=The Standard - C|url=http://www.iso-9899.info/wiki/The_Standard|website=www.iso-9899.info}}</ref> === C23 === {{Main article|C23 (C standard revision)|l1=C23}} C23 was published in October 2024, and is the current [[open standard|standard]] for the [[C (programming language)|C programming language]].<ref name="ISO2024">{{cite web |title=ISO/IEC 9899:2024 - Information technology β Programming languages β C |url=https://www.iso.org/standard/82075.html}}</ref> ===Other related ISO publications=== As part of the standardization process, ISO/IEC also publishes [[International Organization for Standardization#International standards and other publications|technical reports and specifications]] related to the C language: * ISO/IEC TR 19769:2004,<ref>{{cite web|url=https://www.iso.org/standard/33907.html|title=ISO/IEC TR 19769:2004|publisher=International Organization for Standardization}}</ref> on library extensions to support Unicode transformation formats, integrated into C11 * ISO/IEC TR 24731-1:2007,<ref>{{cite web|url=https://www.iso.org/standard/38841.html|title=ISO/IEC TR 24731-1:2007|publisher=International Organization for Standardization}}</ref> on library extensions to support bounds-checked interfaces, integrated into C11 * ISO/IEC TR 18037:2008,<ref>{{cite web|url=https://www.iso.org/standard/51126.html|title=ISO/IEC TR 18037:2008|publisher=International Organization for Standardization}}</ref> on embedded C extensions * ISO/IEC TR 24732:2009,<ref>{{cite web|url=https://www.iso.org/standard/38842.html|title=ISO/IEC TR 24732:2009|publisher=International Organization for Standardization}}</ref> on [[decimal floating point]] arithmetic, superseded by ISO/IEC TS 18661-2:2015 * ISO/IEC TR 24747:2009,<ref>{{cite web|url=https://www.iso.org/standard/38857.html|title=ISO/IEC TR 24747:2009|publisher=International Organization for Standardization}}</ref> on special mathematical functions, * ISO/IEC TR 24731-2:2010,<ref>{{cite web|url=https://www.iso.org/standard/51678.html|title=ISO/IEC TR 24731-2:2010|publisher=International Organization for Standardization}}</ref> on library extensions to support dynamic allocation functions * ISO/IEC TS 17961:2013,<ref>{{cite web|url=https://www.iso.org/standard/61134.html|title=ISO/IEC TS 17961:2013|publisher=International Organization for Standardization}}</ref> on secure coding in C * ISO/IEC TS 18661-1:2014,<ref>{{cite web|url=https://www.iso.org/standard/63146.html|title=ISO/IEC TS 18661-1:2014|publisher=International Organization for Standardization}}</ref> on [[IEEE floating point|IEC 60559:2011]]-compatible binary floating-point arithmetic * ISO/IEC TS 18661-2:2015,<ref>{{cite web|url=https://www.iso.org/standard/68882.html|title=ISO/IEC TS 18661-2:2015|publisher=International Organization for Standardization}}</ref> on IEC 60559:2011-compatible [[decimal floating point]] arithmetic * ISO/IEC TS 18661-3:2015,<ref>{{cite web|url=https://www.iso.org/standard/65615.html|title=ISO/IEC TS 18661-3:2015|publisher=International Organization for Standardization}}</ref> on IEC 60559:2011-compatible interchange and extended floating-point types * ISO/IEC TS 18661-4:2015,<ref>{{cite web|url=https://www.iso.org/standard/65616.html|title=ISO/IEC TS 18661-4:2015|publisher=International Organization for Standardization}}</ref> on IEC 60559:2011-compatible supplementary functions More technical specifications are in development and pending approval, including the fifth and final part of TS 18661, a software transactional memory specification, and parallel library extensions.<ref>{{cite web |url=https://en.cppreference.com/w/c/experimental |access-date=16 January 2016 |title=Experimental C features |website=cppreference.com }}</ref> ==Support from major compilers== ANSI C is supported by almost all the widely used compilers. GCC and Clang are two major C compilers popular today, both based on the C11 with updates including changes from later specifications such as C17.<ref>{{Cite web|url=https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Standards.html#C-Language|work=Using the GNU Compiler Collection (GCC) |title=2 Language Standards Supported by GCC - 2.1 C Language |publisher=GCC, the GNU Compiler Collection |access-date=2019-02-05}}</ref><ref>{{Cite web|url=https://clang.llvm.org/compatibility.html#c|title=Language Compatibility|website=Clang C Language Family Frontend for LLVM |access-date=2019-02-05}}</ref> Any source code written ''only'' in standard C and without any hardware dependent assumptions is virtually guaranteed to compile correctly on any [[system platform|platform]] with a conforming C implementation. Without such precautions, most 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 [[Graphical user interface|GUI]] libraries, or to the reliance on compiler- or platform-specific attributes such as the exact size of certain data types and byte [[endianness]]. ===Compliance detectability=== To mitigate the differences between [[K&R C]] and the ANSI C standard, the <code>__STDC__</code> ("standard c") macro can be used to split code into ANSI and K&R sections. <syntaxhighlight lang="c"> #if defined(__STDC__) && __STDC__ extern int getopt(int, char * const *, const char *); #else extern int getopt(); #endif </syntaxhighlight> In the above example, a prototype is used in a function declaration for ANSI compliant implementations, while an obsolescent non-prototype declaration is used otherwise. Those are still ANSI-compliant as of C99. Note how this code checks both definition and evaluation: this is because some implementations may set <code>__STDC__</code> to zero to indicate non-ANSI compliance.<ref>{{Cite web|url=https://www.ibm.com/support/knowledgecenter/SSPSQF_9.0.0/com.ibm.xlcpp111.aix.doc/language_ref/cplr367.html|title=Standard predefined macro names|website=www.ibm.com|language=en-US|access-date=2019-04-10}}</ref> == Compiler support == List of compilers supporting ANSI C: * [[Acorn C/C++|Acornsoft ANSI C]] (first version in 1988, revised in 1989) * [[Amsterdam Compiler Kit]] (C K&R and C89/90) * [[ARM Holdings|ARM]] RealView * [[Clang]] (full C89/C90, partial C99, C11, C17, C23 and C2y), using [[LLVM]] backend * [[GNU Compiler Collection|GCC]] (full C89/90, C99, C11, partial C17 and some C23 and experimental/incomplete C2y) * HP C/ANSI C compiler (C89 and C99)<ref>{{cite web|title=HP C/ANSI C developer's bundle|url=https://www.hp.com/go/c|access-date=2015-07-12}}</ref> * [[IBM XL C/C++]] (C11, starting with version 12.1)<ref>[https://www.ibm.com/developerworks/rational/library/support-iso-c11/index.html Support for ISO C11 added to IBM XL C/C++ compilers]</ref> * [[Intel C++ Compiler|Intel's ICC]] (later versions are based on [[clang]], and have its support!-- or more or less, seemingly missing some support/or table wrong, not updated? And can have more support than clang despite when using it? -->) * [[LabWindows/CVI]] * [[LCC (compiler)|LCC]] * [[Oracle Developer Studio]] * [[OpenWatcom]] (C89/90 and some C99) * [[Visual C++|Microsoft Visual C++]] (C89/90 and some C99, C11, C17, mostly missing C23)<ref>{{Cite web |last=TylerMSFT |title=Install C11 and C17 support in Visual Studio |url=https://learn.microsoft.com/en-us/cpp/overview/install-c17-support |access-date=2025-04-15 |website=learn.microsoft.com |language=en-us}}</ref><ref>{{Cite web |title=typeof, __typeof__ (C23) |url=https://learn.microsoft.com/en-us/cpp/c-language/typeof-c |access-date=2025-04-15 |website=learn.microsoft.com |language=en-us}}</ref><ref>{{Cite web |title=Developer Community |url=https://developercommunity.visualstudio.com/t/Please-add-support-for-C23-in-MSVC/10284062 |access-date=2025-04-15 |website=developercommunity.visualstudio.com |language=en}}</ref> * [[Pelles C]] (C99 and C11. Windows only.)<ref>[http://www.smorgasbordet.com/pellesc/ link to Pelles C pages]</ref> * [[vbcc]] (C89/90 and C99) * [[Tiny C Compiler]] (C89/90 and some C99) ==See also== {{Portal|Computer programming}} * [[Behavioral Description Language]] * [[Compatibility of C and C++]] * [[C++23]], [[C++20]], [[C++17]], [[C++14]], [[C++11]], [[C++03]], [[C++98]], versions of the C++ programming language standard * [[C++ Technical Report 1]] ==References== {{Reflist}} ==Further reading== * {{Cite book |first=Axel-Tobias |last=Schreiner |title=Object Oriented Programming with ANSI-C |year=1993 |publisher=Hanser |isbn=3-446-17426-5 }} == External links == * [http://www.open-std.org/jtc1/sc22/wg14/ ISO C working group] * [https://web.archive.org/web/20161223125339/http://flash-gordon.me.uk/ansi.c.txt ''Draft ANSI C Standard'' (ANSI X3J11/88-090)] (May 13, 1988), [https://groups.google.com/group/comp.lang.c/msg/20b174b18cdd919d?hl=en Third Public Review] * [https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0BxVCLS4f8Sg5NWZmM2NjZWEtYmExMS00Y2EzLWE3ZTMtNzFmYjYwYzBiOTIw&hl=en_US ''Draft ANSI C Rationale'' (ANSI X3J11/88-151)] (Nov 18, 1988) * [https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B-3PfyBhOSOxOTdjYmM1N2ItMmE0ZC00OGE3LTllODUtZDNkMDMzYWU3NDlk&hl=en_US ''C Information Bulletin #1'' (ANSI X3J11/93-007)] (May 27, 1992) * [http://www.quut.com/c/ANSI-C-grammar-y.html ANSI C Yacc grammar] ** [http://www.lysator.liu.se/c/ANSI-C-grammar-l.html ANSI C grammar, Lex specification] {{ISO standards}} {{List of International Electrotechnical Commission standards}} {{CProLang}} {{Authority control}} {{DEFAULTSORT:Ansi C}} [[Category:American National Standards Institute standards]] [[Category:C (programming language)]] [[Category:Programming language standards]]
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:About
(
edit
)
Template:Authority control
(
edit
)
Template:CProLang
(
edit
)
Template:C language revisions
(
edit
)
Template:Cite book
(
edit
)
Template:Cite magazine
(
edit
)
Template:Cite web
(
edit
)
Template:ISO standards
(
edit
)
Template:List of International Electrotechnical Commission standards
(
edit
)
Template:Main article
(
edit
)
Template:Portal
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Search
Search
Editing
ANSI C
Add topic