C language revisions |
---|
C23, formally ISO/IEC 9899:2024, is the current open standard for the C programming language, which supersedes C17 (standard ISO/IEC 9899:2018). [1] It was started in 2016 informally as C2x, [2] and was published on October 31, 2024. [3] The freely available draft most similar to the one published is document N3220 [4] (see Available texts, below). The first WG14 meeting for the C2x draft was held in October 2019, [5] virtual remote meetings were held in 2020 due to the COVID-19 pandemic, then various teleconference meetings continued to occur through 2024.
In C23, the value of __STDC_VERSION__ changes from 201710L to 202311L. The common names "C17" and "C23" reflect these values, which are frozen prior to final adoption, rather than the years in the ISO standards identifiers (9899:2018 and 9899:2024).
Changes integrated into the latest working draft of C23 are listed below. [6]
memset_explicit()
function in <string.h>
to erase sensitive data, where memory store must always be performed regardless of optimizations. [7] memccpy()
function in <string.h>
to efficiently concatenate strings – similar to POSIX and SVID C extensions. [8] strdup()
and strndup()
functions in <string.h>
to allocate a copy of a string – similar to POSIX and SVID C extensions. [9] memalignment()
function in <stdlib.h>
to determine the byte alignment of a pointer. [10] <stdbit.h>
to examine many integer types. All start with stdc_
to minimize conflict with legacy code and 3rd party libraries. [11] *
with uc
, us
, ui
, ul
, ull
for five function names, or blank for a type-generic macro. [11] stdc_count_ones*()
and stdc_count_zeros*()
to count number of 1 or 0 bits in value. [11] stdc_leading_ones*()
and stdc_leading_zeros*()
to count leading 1 or 0 bits in value. [11] stdc_trailing_ones*()
and stdc_trailing_zeros*()
to count trailing 1 or 0 bits in value. [11] stdc_first_leading_one*()
and stdc_first_leading_zero*()
to find first leading bit with 1 or 0 in value. [11] stdc_first_trailing_one*()
and stdc_first_trailing_zero*()
to find first trailing bit with 1 or 0 in value. [11] stdc_has_single_bit*()
to determine if value is an exact power of 2 (return true if and only if there is a single 1 bit). [11] stdc_bit_floor*()
to determine the largest integral power of 2 that is not greater than value. [11] stdc_bit_ceil*()
to determine the smallest integral power of 2 that is not less than value. [11] stdc_bit_width*()
to determine number of bits to represent a value. [11] timegm()
function in <time.h>
to convert time structure into calendar time value - similar to function in glibc and musl libraries. [12] <math.h>
functions based on IEEE 754-2019 recommendations, such as trigonometry functions operating on units of and exp10
. [13] %b
binary conversion specifier to printf()
function family. [14] %b
binary conversion specifier to scanf()
function family. [14] 0b
and 0B
binary conversion support to strtol()
and wcstol()
function families. [14] bsearch()
, bsearch_s()
, memchr()
, strchr()
, strpbrk()
, strrchr()
, strstr()
, and their wide counterparts wmemchr()
, wcschr()
, wcspbrk()
, wcsrchr()
, wcsstr()
return a const qualified object if one was passed to them. [15] #elifdef
and #elifndef
directives, [16] which are essentially equivalent to #elif defined
and #elif !defined
. Both directives were added to C++23 standard and GCC 12. [17] #embed
directive for binary resource inclusion and __has_embed
allowing the availability of a resource to be checked by preprocessor directives. [18] #warning
directive for diagnostics. [19] __has_include
allowing the availability of a header to be checked by preprocessor directives. [20] __has_c_attribute
allowing the availability of an attribute to be checked by preprocessor directives. [21] (see "C++ compatibility" group for new attribute feature)__VA_OPT__
functional macro for variadic macros which expands to its argument only if a variadic argument has been passed to the containing macro. [22] nullptr_t
, a null pointer type. [23] _BitInt(N)
and unsigned_BitInt(N)
types for bit-precise integers. Add BITINT_MAXWIDTH
macro for maximum bit width. [24] [25] ckd_add()
, ckd_sub()
, ckd_mul()
macros for checked integer operations. [26] const
with arrays. [28] typeof(...)
operator. [29] auto
keyword was changed to cause type inference while also retaining its old meaning of a storage class specifier if used alongside a type. Unlike C++, C23 allows type inference only for object definitions (no inferring function return type or function parameter type). [30] intmax_t
(N2888). [32] nullptr
constant for nullptr_t
type. [23] wb
and uwb
integer literal suffixes for _BitInt(N)
and unsigned_BitInt(N)
types, [33] such as 6uwb
yields an unsigned _BitInt(3)
, and -6wb
yields a signed _BitInt(4)
which has three value bits and one sign bit.0b
and 0B
binary literal constant prefixes, [34] such as 0b10101010
(equating to 0xAA).'
digit separator to literal constants, [35] such as 0xFE'DC'BA'98
(equating to 0xFEDCBA98), 299'792'458
(equating to 299792458), 1.414'213'562
(equating to 1.414213562). enum
. [36] enum
s with no fixed underlying type to store values that are not representable by int
. [37] true
and false
keywords. [38] alignas
, alignof
, bool
, static_assert
, thread_local
keywords. Previously defined keywords become alternative spellings: _Alignas
, _Alignof
, _Bool
, _Static_assert
, _Thread_local
. [39] _BitInt
keyword (see "types" group)typeof
and typeof_unqual
keywords (see "types" group)nullptr
keyword (see "constants" group)constexpr
keyword (see "other" group)_Decimal32
, _Decimal64
, _Decimal128
keywords for (optional) decimal floating-point arithmetic (see "other" group){}
(including initialization of VLAs). [42] va_start
macro no longer needs a second argument nor does it evaluate any argument after the first one if present. [43] [[]]
. In addition to C++11 attributes listed below, add new attributes: _Static_assert
for compatibility with C++17. [46] void foo()
) are understood as taking no arguments (see removal of K&R function declarations){}
, variadic functions without named argument, C++11 style attributes, _Static_assert
(see Syntax). For labels at the end of compound statements a corresponding change was made to C++23. [47] [[deprecated]]
, [49] [[fallthrough]]
, [50] [[maybe_unused]]
, [51] [[nodiscard]]
, [52] and [[noreturn]]
attribute for compatibility with C++11, then deprecate _Noreturn
, noreturn
, header <stdnoreturn.h>
features introduced in C11. [53] Duplicate attributes are allowed for compatibility with C++23. [54] All standard attributes can also be surrounded by double underscores (e.g. [[__deprecated__]]
is equivalent to [[deprecated]]
).u8
prefix for character literals to represent UTF-8 encoding for compatibility with C++17. [55] [56] #elifdef
and #elifndef
preprocessing directives for compatibility with C++23. [16] (see "preprocessor" group) constexpr
specifier for objects but not functions, unlike C++'s equivalent. [59] char8_t
type for storing UTF-8 encoded data and change the type of u8 character constants and string literals to char8_t
. Also, the functions mbrtoc8()
and c8rtomb()
to convert a narrow multibyte character to UTF-8 encoding and a single code point from UTF-8 to a narrow multibyte character representation respectively. [60] char16_t
strings and literals shall be UTF-16 encoded, and all char32_t
strings and literals shall be UTF-32 encoded, unless otherwise explicitly specified. [61] Some old obsolete features are either removed or deprecated from the working draft of C23:
*_HAS_SUBNORM
macros in <float.h>
are obsolescent features. [67] The following compilers implement an experimental compiler flag to support this standard:
Like other editions of the C standard, the official ISO text of the standard is not freely available.
The latest working draft pre-C23 that was made public was N3096, [6] dated 2023-04-01. In the months that followed this draft, hundreds of changes [71] were made before producing the working draft N3149 dated 2023-07-09 and the official draft standard N3219 dated 2024-02-22. [71] [72] Neither of these later drafts is public. [71] [72]
On the same date that the draft standard N3219 was announced, a new working draft N3220 [4] was made public. While this document is officially described [72] as a draft of the future version "C2Y" of the standard, the accompanying "Editor's Report" specifies that N3220 differs from the draft C23 standard N3219 only by a fix to one footnote in Annex K. [72]
ANSI C, ISO C, and Standard C are successive standards for the 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. Software developers writing in C are encouraged to conform to the standards, as doing so helps portability between compilers.
C is a general-purpose programming language. It was created in the 1970s by Dennis Ritchie and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems code, device drivers, and protocol stacks, but its use in application software has been decreasing. C is commonly used on computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.
In computer science, an integer is a datum of integral data type, a data type that represents some range of mathematical integers. Integral data types may be of different sizes and may or may not be allowed to contain negative values. Integers are commonly represented in a computer as a group of binary digits (bits). The size of the grouping varies so the set of integer sizes available varies between different types of computers. Computer hardware nearly always provides a way to represent a processor register or memory address as an integer.
UTF-32 (32-bit Unicode Transformation Format), sometimes called UCS-4, is a fixed-length encoding used to encode Unicode code points that uses exactly 32 bits (four bytes) per code point (but a number of leading bits must be zero as there are far fewer than 232 Unicode code points, needing actually only 21 bits). In contrast, all other Unicode transformation formats are variable-length encodings. Each 32-bit value in UTF-32 represents one Unicode code point and is exactly equal to that code point's numerical value.
The C preprocessor is the macro preprocessor for several computer programming languages, such as C, Objective-C, C++, and a variety of Fortran languages. The preprocessor provides inclusion of header files, macro expansions, conditional compilation, and line control.
The C standard library, sometimes referred to as libc, is the standard library for the C programming language, as specified in the ISO C standard. Starting from the original ANSI C standard, it was developed at the same time as the C library POSIX specification, which is a superset of it. Since ANSI C was adopted by the International Organization for Standardization, the C standard library is also called the ISO C library.
This is a list of operators in the C and C++ programming languages. All the operators listed exist in C++; the column "Included in C", states whether an operator is also present in C. Note that C does not support operator overloading.
C99 is a past version of the C programming language open standard. It extends the previous version (C90) with new features for the language and the standard library, and helps implementations make better use of available computer hardware, such as IEEE 754-1985 floating-point arithmetic, and compiler technology. The C11 version of the C programming language standard, published in 2011, updates C99.
A variadic macro is a feature of some computer programming languages, especially the C preprocessor, whereby a macro may be declared to accept a varying number of arguments.
The void type, in several programming languages derived from C and Algol68, is the return type of a function that returns normally, but does not provide a result value to its caller. Usually such functions are called for their side effects, such as performing some task or writing to their output parameters. The usage of the void type in such context is comparable to procedures in Pascal and syntactic constructs which define subroutines in Visual Basic. It is also similar to the unit type used in functional programming languages and type theory. See Unit type#In programming languages for a comparison.
In the C programming language, data types constitute the semantics and characteristics of storage of data elements. They are expressed in the language syntax in form of declarations for memory locations or variables. Data types also determine the types of operations or methods of processing of data elements.
The C and C++ programming languages are closely related but have many significant differences. C++ began as a fork of an early, pre-standardized C, and was designed to be mostly source-and-link compatible with C compilers of the time. Due to this, development tools for the two languages are often integrated into a single product, with the programmer able to specify C or C++ as their source language.
assert.h is a header file in the C standard library. It defines the C preprocessor macro assert
and implements runtime assertion in C.
C++11 is a version of a joint technical standard, ISO/IEC 14882, by the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC), for the C++ programming language. C++11 replaced the prior version of the C++ standard, named C++03, and was later replaced by C++14. The name follows the tradition of naming language versions by the publication year of the specification, though it was formerly named C++0x because it was expected to be published before 2010.
C11, is a past standard for the C programming language. It replaced C99 and has been superseded by C17. C11 mainly standardizes features already 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 certain features optional, to make it easier to comply with the core language standard.
The C programming language has a set of functions implementing operations on strings in its standard library. Various operations, such as copying, concatenation, tokenization and searching are supported. For character strings, the standard library uses the convention that strings are null-terminated: a string of n characters is represented as an array of n + 1 elements, the last of which is a "NUL character" with numeric value 0.
C++17 is a version of the ISO/IEC 14882 standard for the C++ programming language. C++17 replaced the prior version of the C++ standard, called C++14, and was later replaced by C++20.
C++20 is a version of the ISO/IEC 14882 standard for the C++ programming language. C++20 replaced the prior version of the C++ standard, called C++17, and was later replaced by C++23. The standard was technically finalized by WG21 at the meeting in Prague in February 2020, had its final draft version announced in March 2020, was approved on 4 September 2020, and published in December 2020.
C17, formally ISO/IEC 9899:2018, is an open standard for the C programming language, prepared in 2017 and published in July 2018. It replaced C11, and is superseded by C23 since October 2024. Since it was under development in 2017, and officially published in 2018, C17 is sometimes referred to as C18.
C++23 is the name for the version of the International Organization for Standardization (ISO) and International Electrotechnical Commission (IEC) 14882 standard for the C++ programming language that follows C++20. The final draft of this version is N4950.