C11 is the unofficial name of the current standard for the C programming language (ISO/IEC 9899:2011[1]), informally known as C1X before final standard publication. It replaces the previous C standard, informally known as C99. This new version mainly standardizes features that have already been supported by common contemporary compilers, and includes a detailed memory model to better support multiple threads of execution. Due to delayed availability of conforming C99 implementations, C11 makes more features optional, to make it easier to comply with the core language standard.[2][3]
The final draft, N1570[4], was published in April 2011. The new standard passed its final draft review on October 10, 2011 and was officially ratified by ISO and published as ISO/IEC 9899:2011 on 8th December, 2011, with no comments requiring resolution from participating national bodies.
GCC version 4.6 has added initial support for some features from the C11 draft.[5]
Contents |
The standard includes several changes to the C99 language and library specifications, such as:[6]
_Alignas
specifier, alignof
operator, aligned_alloc
function, <stdalign.h>
header file)_Noreturn
function specifier_Generic
keyword. For example, the following macro cbrt(x)
translates to cbrtl(x)
, cbrt(x)
or cbrtf(x)
depending on the type of x
:
#define cbrt(X) _Generic((X), long double: cbrtl, \
default: cbrt, \
float: cbrtf)(X)
_Thread_local
storage-class specifier, <threads.h>
header including thread creation/management functions, mutex, condition variable and thread-specific storage functionality, as well as the _Atomic
type qualifier and <stdatomic.h>
for uninterruptible object access).char16_t
and char32_t
types for storing UTF-16/UTF-32 encoded data, including conversion functions in <uchar.h>
and the corresponding u
and U
string literal prefixes, as well as the u8
prefix for UTF-8 encoded literals).gets
function, deprecated in the current C language standard revision, ISO/IEC 9899:1999/Cor.3:2007(E), in favor of a new safe alternative, gets_s
.struct T { int tag; union { float x; int n; }; };
.#if
and #error
, when types are understood by the translator."…x"
) for fopen. This behaves like O_CREAT|O_EXCL
in POSIX, which is commonly used for lock files.quick_exit
function as a third way to terminate a program, intended to do at least minimal deinitialization if termination with exit
fails[8].real + imaginary*I
might not yield the expected value if imaginary
is infinite or NaN)[9].The new revision allows implementations not to support certain parts of the standard — including some that had been mandatory to support in the 1999 revision.[10] Programs can use predefined macros to determine whether an implementation supports a certain feature or not.
Feature | Feature test macro | Availability in C99[11] |
---|---|---|
Analyzability (Annex L) | __STDC_ANALYZABLE__ |
Not available |
IEC 60559 floating-point arithmetic (Annex F) | __STDC_IEC_559__ |
Optional |
IEC 60559 compatible complex arithmetic (Annex G) | __STDC_IEC_559_COMPLEX__ |
Optional |
Bounds-checking interfaces (Annex K) | __STDC_LIB_EXT1__ |
Not available |
Complex types (<complex.h> ) |
__STDC_NO_COMPLEX__ |
Mandatory |
Multithreading (<threads.h> ) |
__STDC_NO_THREADS__ |
Not available |
Atomic primitives and types (<stdatomic.h> and the _Atomic type qualifier)[12] |
__STDC_NO_ATOMICS__ |
Not available |
Variable length arrays | __STDC_NO_VLA__ |
Mandatory |
Preceded by C99 |
C language standards | Most recent |
|