A source file does not state which version of C it was written for. The compiler is told,
with options such as GCC’s -std=c17, or uses its default. A program can test the
version with the __STDC_VERSION__ macro, which C95 introduced.
Summary
| Name | Standard | Published | __STDC_VERSION__ |
|---|---|---|---|
| K&R C | The book The C Programming Language, by Kernighan and Ritchie | 1978 | Not defined |
| C89 | ANSI X3.159-1989 | 1989 | Not defined |
| C90 | ISO/IEC 9899:1990 | 1990 | Not defined |
| C95 | ISO/IEC 9899:1990/AMD1:1995 | 1995 | 199409L |
| C99 | ISO/IEC 9899:1999 | 1999 | 199901L |
| C11 | ISO/IEC 9899:2011 | December 2011 | 201112L |
| C17 | ISO/IEC 9899:2018 | June 2018 | 201710L |
| C23 | ISO/IEC 9899:2024 | October 2024 | 202311L |
C89 and C90 are the same language with different section numbers. C17 is sometimes called
C18, from its publication year. A compiler that conforms to any standard from C89 onwards
defines __STDC__ as 1.
K&R C
Brian Kernighan and Dennis Ritchie’s book, first published in 1978, served as the informal definition of the language for over a decade. K&R C had:
- 28 keywords, listed below.
longandunsignedintegers, the standard input and output library, and/* */comments.- Compound assignment written
+=and so on, replacing the older=+form because of ambiguities likei=-10. - Implicit
int, and no way to declare parameter types in a function declaration. - Function definitions in the old style.
Its keywords were auto break case char
continue default do double else
entry extern float for goto
if int long register return
short sizeof static struct switch
typedef union unsigned while.
entry was reserved but never given a meaning.
Compilers soon added void functions, structure assignment, structures as function
results, and enumerations. These features were not in the book.
C89 and C90
The first standard, developed by an ANSI committee.
- Function prototypes, with the old-style form kept and marked obsolescent.
voidandvoid *.const,volatileandsigned.- Enumerations, and assignment and passing of structures.
long double.- A standard library with defined headers.
- The preprocessor operators
#,##anddefined, and the directives#elif,#error,#pragmaand the null directive. - Trigraphs and wide characters.
- The predefined macros
__FILE__,__LINE__,__DATE__,__TIME__and__STDC__.
C95
Amendment 1 to C90 was a small update, published in 1995.
- Digraphs, which are alternative spellings for some punctuators.
- The macro
__STDC_VERSION__. - The headers
<iso646.h>,<wchar.h>and<wctype.h>.
C99
C99 was a large revision. Technical corrigenda followed in 2001, 2004 and 2007.
Language additions:
//comments._Bool,long long, and extended integer types._Complexand_Imaginarytypes.- Mixed declarations and statements, and declarations in
forinitialisers. - Variable length arrays and flexible array members.
- Designated initialisers and compound literals.
inlineandrestrict, andstaticand qualifiers in array parameter brackets.- Hexadecimal floating constants, and universal character names.
- Variadic macros and the
_Pragmaoperator. __func__, a trailing comma in enumerator lists, and an implicitreturn 0at the end ofmain.- Division that truncates toward zero, increased translation limits, and the standard floating-point pragmas.
New headers: <complex.h>, <fenv.h>,
<inttypes.h>, <stdbool.h>, <stdint.h>
and <tgmath.h>. New library features include snprintf,
_Exit, va_copy, isblank, and printf length
modifiers such as ll and z.
Removed: implicit int and implicit function declarations. C99 also deprecated
gets.
C11
Language additions:
_Thread_localand the_Atomictype, with a memory model._Alignasand_Alignof._Genericselection and_Noreturn._Static_assert.- Anonymous structures and unions.
uandUcharacter constants, andu8,uandUstring literals.- A finer description of evaluation order, through sequenced before.
New headers: <stdalign.h>, <stdatomic.h>,
<stdnoreturn.h>, <threads.h> and
<uchar.h>. Annex K, the bounds-checking interfaces, is also new.
C11 made complex types and variable length arrays optional, and removed
gets.
C17
C17 is a defect-correction release. It adds no new language or library features, and only
changes __STDC_VERSION__ and resolves defect reports. It also deprecates
ATOMIC_VAR_INIT and calling realloc with a size of zero.
C23
C23 is a substantial revision, published as ISO/IEC 9899:2024. Its language additions include:
- The keywords
bool,true,false,alignas,alignof,static_assertandthread_local, replacing older spellings. nullptrand the typenullptr_t.typeofandtypeof_unqual, andautowith type inference.constexprobjects.- Attributes, such as
[[nodiscard]]and[[maybe_unused]]. - Bit-precise integers (
_BitInt), and decimal floating types. - Binary constants (
0b1010), and digit separators (1'000). u8character constants, andchar8_tas the element type ofu8strings.- Enumerations with a fixed underlying type.
#embed,#elifdef,#elifndef,#warning,__has_includeand__VA_OPT__.- The empty initialiser
= {}, unnamed parameters in definitions, and labels before declarations and closing braces. - Single-argument
static_assert, and variadic functions with no named parameter. - Identifiers defined in terms of Unicode Standard Annex 31.
New headers: <stdbit.h> and <stdckdint.h>. Library
additions include memset_explicit, strdup, strndup,
memccpy, the b conversion for printf, and
timespec_getres.
Removed:
- Old-style function declarations and definitions.
- Representations of signed integers other than two’s complement.
- Trigraphs.
- Mixed wide string literal concatenation.
reallocwith a size of zero, which is now undefined.static_assertandthread_localas macros, now keywords.
Deprecated: <stdnoreturn.h>, the _Noreturn specifier,
asctime, ctime, __STDC_IEC_559__, and the older
underscore keyword spellings.