C23 (C standard revision)
{{Short description|C programming language standard, current revision}}
{{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).{{cite web |title=History of C |url=https://en.cppreference.com/w/c/language/history |website=cppreference.com |archive-url=https://web.archive.org/web/20221019191546/https://en.cppreference.com/w/c/language/history |archive-date=October 19, 2022 |date=2022-06-27 |url-status=live}} It was started in 2016 informally as C2x,{{cite web |title=WG14-N2086: C2x Charter |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2086.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221222213708/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2086.htm |archive-date=December 22, 2022 |date=2016-09-20 |url-status=live}} and was published on October 31, 2024.{{cite web |title=ISO/IEC PRF 9899 |url=https://www.iso.org/standard/82075.html |website=iso.org |archive-url=http://web.archive.org/web/20240919185914/https://www.iso.org/standard/82075.html |archive-date=September 19, 2024 |url-status=live}} The freely available draft most similar to the one published is document N3220 (see Available texts, below). The first WG14 meeting for the C2x draft was held in October 2019,{{cite web |title=WG14-N2437: Agenda for October 2019 |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2437.htm |website=open-std.org |archive-url=https://web.archive.org/web/20210305073426/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2437.htm |archive-date=March 5, 2021 |date=2019-10-21 |url-status=live}} 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).
Features
Changes integrated into the latest working draft of C23 are listed below.{{cite web |title=WG14-N3096: Draft for ISO/IEC 9899:2024 |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20230402172459/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf |archive-date=April 2, 2023 |date=April 1, 2023 |url-status=live}}
=Standard Library=
==New functions==
- Add
memset_explicit()
function in<string.h>
to erase sensitive data, where memory store must always be performed regardless of optimizations.{{cite web |title=WG14-N2897: memset_explicit() |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2897.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221025074215/https://open-std.org/jtc1/sc22/wg14/www/docs/n2897.htm |archive-date=October 25, 2022 |date=2021-12-27 |url-status=live}} - Add
memccpy()
function in
to efficiently concatenate strings – similar to POSIX and SVID C extensions.{{cite web |title=WG14-N2349: Toward more efficient string copying and concatenation |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2349.htm |website=open-std.org |archive-url=https://web.archive.org/web/20220930092258/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2349.htm |archive-date=September 30, 2022 |date=2019-03-18 |url-status=live}} - Add
strdup()
andstrndup()
functions in
to allocate a copy of a string – similar to POSIX and SVID C extensions.{{cite web |title=WG14-N2353: strdup() and strndup() |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2353.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221224063709/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2353.htm |archive-date=December 24, 2022 |date=2019-03-18 |url-status=live}} - Add
memalignment()
function in<stdlib.h>
to determine the byte alignment of a pointer.{{cite web |title=WG14-N2974: Queryable pointer alignment |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2974.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221013182240/https://www.open-std.org/jtc1/sc22/WG14/www/docs/n2974.pdf |archive-date=October 13, 2022 |date=2022-04-15 |url-status=live}} - Add bit utility functions / macros / types in new header
<stdbit.h>
to examine many integer types. All start withstdc_
to minimize conflict with legacy code and 3rd party libraries.{{cite web |title=WG14-N3022: Modern Bit Utilities |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3022.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221224194734/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3022.htm |archive-date=December 24, 2022 |date=2022-07-06 |url-status=live}} - In the following, replace
*
withuc
,us
,ui
,ul
,ull
for five function names, or blank for a type-generic macro. - Add
stdc_count_ones*()
andstdc_count_zeros*()
to count number of 1 or 0 bits in value. - Add
stdc_leading_ones*()
andstdc_leading_zeros*()
to count leading 1 or 0 bits in value. - Add
stdc_trailing_ones*()
andstdc_trailing_zeros*()
to count trailing 1 or 0 bits in value. - Add
stdc_first_leading_one*()
andstdc_first_leading_zero*()
to find first leading bit with 1 or 0 in value. - Add
stdc_first_trailing_one*()
andstdc_first_trailing_zero*()
to find first trailing bit with 1 or 0 in value. - Add
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). - Add
stdc_bit_floor*()
to determine the largest integral power of 2 that is not greater than value. - Add
stdc_bit_ceil*()
to determine the smallest integral power of 2 that is not less than value. - Add
stdc_bit_width*()
to determine number of bits to represent a value. - Add
timegm()
function in<time.h>
to convert time structure into calendar time value - similar to function in glibc and musl libraries.{{cite web |title=WG14-N2833: Add timegm() as non-optional part of time.h |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2833.htm |website=open-std.org |archive-url=https://web.archive.org/web/20211201062452/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2833.htm |archive-date=December 1, 2021 |date=2021-10-07 |url-status=live}} - New
<math.h>
functions based on IEEE 754-2019 recommendations, such as trigonometry functions operating on units of andexp10
.See N3096 § B.11 for a useful overview. The functions were added in separate documents: N2488, its updated versions, and its refs.
==Existing functions==
- Add
%b
binary conversion specifier toprintf()
function family.{{cite web |title=WG14-N2630: formatted input/output of binary integer numbers |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2630.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221214154315/https://open-std.org/JTC1/SC22/WG14/www/docs/n2630.pdf |archive-date=December 14, 2022 |date=2021-01-01 |url-status=live}} - Add
%b
binary conversion specifier toscanf()
function family. - Add
0b
and0B
binary conversion support tostrtol()
andwcstol()
function families. - Make the functions
bsearch()
,bsearch_s()
,memchr()
,strchr()
,strpbrk()
,strrchr()
,strstr()
, and their wide counterpartswmemchr()
,wcschr()
,wcspbrk()
,wcsrchr()
,wcsstr()
return a const qualified object if one was passed to them.{{cite web |title=WG14-N3020: Qualifier-preserving standard library functions |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3020.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221013190826/https://www.open-std.org/jtc1/sc22/WG14/www/docs/n3020.pdf |archive-date=October 13, 2022 |date=2022-06-13 |url-status=live}}
=Preprocessor=
- Add {{C-lang|#elifdef}} and {{C-lang|#elifndef}} directives,{{cite web |title=WG14-N2645: Add support for preprocessing directives #elifdef and #elifndef |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2645.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221128133337/https://open-std.org/JTC1/SC22/WG14/www/docs/n2645.pdf |archive-date=November 28, 2022 |date=2020-01-25 |url-status=live}} which are essentially equivalent to {{C-lang|#elif defined}} and {{C-lang|#elif !defined}}. Both directives were added to {{nowrap|C++23}} standard and GCC 12.{{cite web |title=GCC 12 Adds Support For New #elifdef #elifndef Directives |url=https://www.phoronix.com/news/GCC-12-elifdef-elifndef |website=phoronix |archive-url=https://web.archive.org/web/20221227050002/https://www.phoronix.com/news/GCC-12-elifdef-elifndef |archive-date=December 27, 2022 |date=May 12, 2021 |url-status=live}}
- Add {{C-lang|#embed}} directive for binary resource inclusion and {{C-lang|__has_embed}} allowing the availability of a resource to be checked by preprocessor directives.{{cite web |title=WG14-N3017: #embed - a scannable, tooling-friendly binary resource inclusion mechanism |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3017.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221224045304/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3017.htm |archive-date=December 24, 2022 |date=2022-06-27 |url-status=live}}
- Add {{C-lang|#warning}} directive for diagnostics.{{cite web |title=WG14-N2686: #warning |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2686.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221128133337/https://open-std.org/JTC1/SC22/WG14/www/docs/n2686.pdf |archive-date=November 28, 2022 |date=2022-07-22 |url-status=live}}
- Add {{C-lang|__has_include}} allowing the availability of a header to be checked by preprocessor directives.{{cite web |title=WG14-N2799: __has_include for C |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2799.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221224103617/https://open-std.org/JTC1/SC22/WG14/www/docs/n2799.pdf |archive-date=December 24, 2022 |date=2021-08-30 |url-status=live}}
- Add {{C-lang|__has_c_attribute}} allowing the availability of an attribute to be checked by preprocessor directives.{{cite web |title=WG14-N2553: Querying attribute support |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2553.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221014221314/https://open-std.org/JTC1/SC22/WG14/www/docs/n2553.pdf |archive-date=October 14, 2022 |date=2020-08-04 |url-status=live}} (see "{{nowrap|C++}} compatibility" group for new attribute feature)
- Add {{C-lang|__VA_OPT__}} functional macro for variadic macros which expands to its argument only if a variadic argument has been passed to the containing macro.{{cite web |title=WG14-N3033: Comma omission and comma deletion |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3033.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221227031727/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3033.htm |archive-date=December 27, 2022 |date=2022-07-20 |url-status=live}}
=Types=
- Add nullptr_t, a null pointer type.
- Add {{C-lang|_BitInt(N)}} and {{C-lang|unsigned _BitInt(N)}} types for bit-precise integers. Add {{C-lang|BITINT_MAXWIDTH}} macro for maximum bit width.{{cite web |title=WG14-N2763: Adding a Fundamental Type for N-bit integers |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2763.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221227055250/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2763.pdf |archive-date=December 27, 2022 |date=2021-06-21 |url-status=live}}{{cite web |title=WG14-N3035: _BitInt Fixes |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3035.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221013182206/https://www.open-std.org/jtc1/sc22/WG14/www/docs/n3035.pdf |archive-date=October 13, 2022 |date=2022-07-21 |url-status=live}}
- Add
ckd_add()
,ckd_sub()
,ckd_mul()
macros for checked integer operations.{{cite web |title=WG14-N2867: Checked N-Bit Integers |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2867.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221214154907/https://open-std.org/JTC1/SC22/WG14/www/docs/n2867.pdf |archive-date=December 14, 2022 |date=2021-11-28 |url-status=live}} - Variably-modified types (but not VLAs which are automatic variables allocated on the stack) become a mandatory feature.{{cite web |title=WG14-N2778: Variably-Modified Types |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2778.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221222053411/https://open-std.org/jtc1/sc22/wg14/www/docs/n2778.pdf |archive-date=December 22, 2022 |date=2021-07-11 |url-status=live}}
- Better support for using
const
with arrays.{{cite web |title=WG14-N2607: Compatibility of Pointers to Arrays with Qualifiers |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2607.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221013182946/https://www.open-std.org/jtc1/sc22/WG14/www/docs/n2607.pdf |archive-date=October 13, 2022 |date=2020-10-31 |url-status=live}} - Standardization of the
typeof(...)
operator.{{cite web |title=WG14-N2899: Not-so-magic - typeof for C |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2899.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221224044528/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2899.htm |archive-date=December 24, 2022 |date=2022-01-21 |url-status=live}} - The meaning of the {{C-lang|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).{{cite web |title=WG14-N3007: Type inference for object definitions |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3007.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221224105654/https://open-std.org/JTC1/SC22/WG14/www/docs/n3007.htm |archive-date=December 24, 2022 |date=2022-06-10 |url-status=live}}
- Compatibility rules for structure, union, and enumerated types were changed to allow a redeclaration of a compatible type with the same tag.{{cite web |title=WG14-N3037: Improved Rules for Tag Compatibility (updates N3032) |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3037.pdf}}
- Exact-width integer may now exceed {{code|intmax_t}} (N2888).{{cite web |title=C23 is Finished: Here is What is on the Menu |url=https://thephd.dev/c23-is-coming-here-is-what-is-on-the-menu |website=The Pasture |language=en |date=31 July 2022}}
=Constants=
- Add nullptr constant for
nullptr_t
type.{{cite web |title=WR14-N3042: Introduce the nullptr constant |url=https://open-std.org/JTC1/SC22/WG14/www/docs/n3042.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221224043228/https://open-std.org/JTC1/SC22/WG14/www/docs/n3042.htm |archive-date=December 24, 2022 |date=2022-07-22 |url-status=live}} - Add
wb
anduwb
integer literal suffixes for {{C-lang|_BitInt(N)}} and {{C-lang|unsigned _BitInt(N)}} types,{{cite web |title=WG14-N2775: Literal suffixes for bit-precise integers |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2775.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221227014728/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2775.pdf |archive-date=December 27, 2022 |date=2021-07-13 |url-status=live}} such as {{C-lang|6uwb}} yields anunsigned _BitInt(3)
, and {{C-lang|-6wb}} yields asigned _BitInt(4)
which has three value bits and one sign bit. - Add
0b
and0B
binary literal constant prefixes,{{cite web |title=WG14-N2549: Allow for binary integer constants |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2549.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221222192818/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2549.pdf |archive-date=December 22, 2022 |date=2020-07-30 |url-status=live}} such as {{C-lang|0b10101010}} (equating to 0xAA). - Add
'
digit separator to literal constants,{{cite web |title=WG14-N2626: Digit separators |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2626.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221219215425/https://open-std.org/JTC1/SC22/WG14/www/docs/n2626.pdf |archive-date=December 19, 2022 |date=2020-12-15 |url-status=live}} such as {{C-lang|0xFE'DC'BA'98}} (equating to 0xFEDCBA98), {{C-lang|299'792'458}} (equating to 299792458), {{C-lang|1.414'213'562}} (equating to 1.414213562). - Add the ability to specify the underlying type of an
enum
.{{cite web |title=WG14-N3030: Enhancements to Enumerations |url=https://open-std.org/JTC1/SC22/WG14/www/docs/n3030.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221126132709/https://open-std.org/JTC1/SC22/WG14/www/docs/n3030.htm |archive-date=November 26, 2022 |date=2022-07-19 |url-status=live}} - Allow {{C-lang|enum}}s with no fixed underlying type to store values that are not representable by {{C-lang|int}}.{{cite web |title=WG14-N3029: Improved Normal Enumerations |url=https://open-std.org/JTC1/SC22/WG14/www/docs/n3029.htm |website=open-std.org |archive-url=https://web.archive.org/web/20230129180341/https://open-std.org/JTC1/SC22/WG14/www/docs/n3029.htm |archive-date=January 29, 2023 |date=2022-07-19 |url-status=live}}
=Keywords=
- Add {{C-lang|true}} and {{C-lang|false}} keywords.{{cite web |title=WG14-N2935: Make false and true first-class language features |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2935.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221121123457/https://open-std.org/JTC1/SC22/WG14/www/docs/n2935.pdf |archive-date=November 21, 2022 |date=2022-02-15 |url-status=live}}
- Add {{C-lang|alignas}}, {{C-lang|alignof}}, {{C-lang|bool}}, {{C-lang|static_assert}}, thread-local storage keywords. Previously defined keywords become alternative spellings: {{C-lang|_Alignas}}, {{C-lang|_Alignof}}, {{C-lang|_Bool}}, {{C-lang|_Static_assert}}, {{C-lang|_Thread_local}}.{{cite web |title=WG14-N2934: Revise spelling of keywords |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2934.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221224132455/https://open-std.org/JTC1/SC22/WG14/www/docs/n2934.pdf |archive-date=December 24, 2022 |date=2022-02-15 |url-status=live}}
- Add {{C-lang|_BitInt}} keyword (see "types" group)
- Add {{C-lang|typeof}} and {{C-lang|typeof_unqual}} keywords (see "types" group)
- Add {{C-lang|nullptr}} keyword (see "constants" group)
- Add {{C-lang|constexpr}} keyword (see "other" group)
- Add {{C-lang|_Decimal32}}, {{C-lang|_Decimal64}}, {{C-lang|_Decimal128}} keywords for (optional) decimal floating-point arithmetic (see "other" group)
=Syntax=
- Labels can appear before declarations and at the end of compound statements.{{cite web |title=WG14-N2508: Free Positioning of Labels Inside Compound Statements |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2508.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221227183107/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2508.pdf |archive-date=December 27, 2022 |date=2020-03-28 |url-status=live}}
- Unnamed parameters in function definitions.{{cite web |title=WG14-N2510: Allowing unnamed parameters in a function definition |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2510.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221224075948/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2510.pdf |archive-date=December 24, 2022 |date=2020-04-09 |url-status=live}}
- Zero initialization with
{}
(including initialization of VLAs).{{cite web |title=WG14-N2900: Consistent, Warningless, and Intuitive Initialization with {} |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2900.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221227181452/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2900.htm |archive-date=December 27, 2022 |date=2022-01-01 |url-status=live}} - Variadic functions no longer need a named argument before the ellipsis and the {{C-lang|va_start}} macro no longer needs a second argument nor does it evaluate any argument after the first one if present.{{cite web |title=WG14-N2975: Relax requirements for variadic parameter lists |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2975.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221128133337/https://open-std.org/JTC1/SC22/WG14/www/docs/n2975.pdf |archive-date=November 28, 2022 |date=2022-04-15 |url-status=live}}
- Add C++11 style attribute syntax{{cite web |title=WG14-N2335: Attributes in C |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2335.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221026060722/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2335.pdf |archive-date=October 26, 2022 |date=2019-03-09 |url-status=live}} using double square brackets {{C-lang|1=}}. In addition to C++11 attributes listed below, add new attributes:
{{Cite web |title=Unsequenced functions |url=https://open-std.org/JTC1/SC22/WG14/www/docs/n2956.htm |access-date=2024-07-18 |website=open-std.org}} allows compiler optimizations for functions producing repeatable outputs only based on their parametersunsequenced
, similar toreproducible
, but for functions whose call order also mattersunsequenced - Add single-argument
_Static_assert
for compatibility with C++17.{{cite web |title=WG14-N2265: Harmonizing static_assert with C++ |url=https://open-std.org/JTC1/SC22/WG14/www/docs/n2265.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20230328064918/https://open-std.org/JTC1/SC22/WG14/www/docs/n2265.pdf |archive-date=March 28, 2023 |date=2018-07-06 |url-status=live}} - Functions with no arguments listed in the prototype (e.g.
void foo()
) are understood as taking no arguments (see removal of K&R function declarations)
=C++ compatibility=
- Various syntax changes improve compatibility with C++, such as labels before declarations, unnamed function arguments, zero initialization with
{}
, 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.{{cite web|url=https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2324r2.pdf|title=Labels at the end of compound statements (C compatibility)|date=2022-01-13}} - Add C++-style attributes (see Syntax). Add attributes{{cite web |title=WG14-N2554: Minor attribute wording cleanups |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2554.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221128133337/https://open-std.org/JTC1/SC22/WG14/www/docs/n2554.pdf |archive-date=November 28, 2022 |date=2020-08-04 |url-status=live}} {{C-lang|1=deprecated}},{{cite web |title=WG14-N2334: The deprecated attribute |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2334.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221019131835/https://open-std.org/JTC1/SC22/WG14/www/docs/n2334.pdf |archive-date=October 19, 2022 |date=2019-01-22 |url-status=live}} {{C-lang|1=fallthrough}},{{cite web |title=WG14-N2408: The fallthrough attribute |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2408.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221225070709/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2408.pdf |archive-date=December 25, 2022 |date=2019-08-11 |url-status=live}} {{C-lang|1=maybe_unused}},{{cite web |title=WG14-N2270: The maybe_unused attribute |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2270.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221225070836/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2270.pdf |archive-date=December 25, 2022 |date=2018-07-06 |url-status=live}} {{C-lang|1=nodiscard}},{{cite web |title=WG14-N2267: The nodiscard attribute |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2267.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221019131846/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2267.pdf |archive-date=October 19, 2022 |date=2018-07-06 |url-status=live}} and {{C-lang|1=noreturn}} attribute for compatibility with C++11, then deprecate {{C-lang|_Noreturn}}, {{C-lang|noreturn}}, header
features introduced in C11.{{cite web |title=WG14-N2764: The noreturn attribute |url=https://open-std.org/JTC1/SC22/WG14/www/docs/n2764.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221225063437/https://open-std.org/JTC1/SC22/WG14/www/docs/n2764.pdf |archive-date=December 25, 2022 |date=2021-06-21 |url-status=live}} Duplicate attributes are allowed for compatibility with C++23.{{cite web |title=WG14-N2557: Allow Duplicate Attributes |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2557.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221128133337/https://open-std.org/JTC1/SC22/WG14/www/docs/n2557.pdf |archive-date=November 28, 2022 |date=2020-09-01 |url-status=live}} All standard attributes can also be surrounded by double underscores (e.g. {{C-lang|1=__deprecated__}} is equivalent to {{C-lang|1=deprecated}}). - Add
u8
prefix for character literals to represent UTF-8 encoding for compatibility with C++17.{{cite web |title=WG14-N2418: Adding the u8 character prefix |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2418.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20230113210023/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2418.pdf |archive-date=January 13, 2023 |date=2019-09-02 |url-status=live}}[https://stackoverflow.com/questions/31970111/what-is-the-point-of-the-utf-8-character-literals-proposed-for-c17#31970297 What is the point of the UTF-8 character literals proposed for C++17?; Stack Overflow.] - Add {{C-lang|#elifdef}} and {{C-lang|#elifndef}} preprocessing directives for compatibility with C++23. (see "preprocessor" group)
=Other features=
- Support for the ISO/IEC 60559:2020, the current version of the IEEE 754 standard for floating-point arithmetic, with extended binary floating-point arithmetic and (optional) decimal floating-point arithmetic.{{cite web |title=WG14-N2341: ISO/IEC TS 18661-2 - Floating-point extensions for C - Part 2: Decimal floating-point arithmetic |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2341.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221121122559/https://open-std.org/JTC1/SC22/WG14/www/docs/n2341.pdf |archive-date=November 21, 2022 |date=February 26, 2019 |url-status=live}}{{cite web |title=WG14-N2601: Annex X - IEC 60559 interchange and extended types |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2601.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221014221322/https://open-std.org/JTC1/SC22/WG14/www/docs/n2601.pdf |archive-date=October 14, 2022 |date=October 15, 2020 |url-status=live}}
- The
constexpr
specifier for objects but not functions, unlike C++'s equivalent.{{cite web |title=WG14-N3018: The constexpr specifier for object definitions |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3018.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221224074302/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3018.htm |archive-date=December 24, 2022 |date=2022-07-06 |url-status=live}} - Add {{C-lang|char8_t}} type for storing UTF-8 encoded data and change the type of u8 character constants and string literals to {{C-lang|char8_t}}. Also, the functions
mbrtoc8()
andc8rtomb()
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.{{cite web |title=WG14-N2653: char8_t: A type for UTF-8 characters and strings (Revision 1) |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2653.htm |website=open-std.org |archive-url=https://web.archive.org/web/20230527110842/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2653.htm |archive-date=May 27, 2023 |date=2021-06-04 |url-status=live}} - Clarify that all {{C-lang|char16_t}} strings and literals shall be UTF-16 encoded, and all {{C-lang|char32_t}} strings and literals shall be UTF-32 encoded, unless otherwise explicitly specified.{{cite web |title=WG14-N2728: char16_t & char32_t string literals shall be UTF-16 & UTF-32 |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2728.htm |website=open-std.org |archive-url=https://web.archive.org/web/20230527110756/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2728.htm |archive-date=May 27, 2023 |date=2021-05-15 |url-status=live}}
- Allow storage class specifiers to appear in compound literal definition.{{cite web |title=WG14-N3038: Introduce storage-class specifiers for compound literals |url=https://open-std.org/JTC1/SC22/WG14/www/docs/n3038.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221126130057/https://open-std.org/JTC1/SC22/WG14/www/docs/n3038.htm |archive-date=November 26, 2022 |date=2022-07-21 |url-status=live}}
Obsolete features
Some old obsolete features are either removed or deprecated from the working draft of C23:
:* Remove trigraphs.{{cite web |title=WG14-N2940: Removing trigraphs??! |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2940.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221026005747/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2940.pdf |archive-date=October 26, 2022 |date=2022-03-02 |url-status=live}}
:* Remove K&R function definitions/declarations (with no information about the function arguments).{{cite web |title=WG14-N2432: Remove support for function definitions with identifier lists proposal |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221227012244/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2432.pdf |archive-date=December 27, 2022 |date=September 25, 2019 |url-status=live}}{{cite web |title=WG14-N2841: No function declarators without prototypes |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221112154740/https://www9.open-std.org/jtc1/sc22/wg14/www/docs/n2841.htm |archive-date=November 12, 2022 |date=2021-10-10 |url-status=live}}
:* Remove representations for signed integers other than two's complement. Two's complement signed integer representation will be required.{{cite web |title=WG14-N2412: Two's complement sign representation |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2412.pdf |website=open-std.org |archive-url=https://web.archive.org/web/20221227174224/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2412.pdf |archive-date=December 27, 2022 |date=August 11, 2019 |url-status=live}}
:* The {{C-lang|*_HAS_SUBNORM}} macros in
are obsolescent features.{{cite web |title=WG14-N2993: Make *_HAS_SUBNORM be obsolescent |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2993.htm |website=open-std.org |archive-url=https://web.archive.org/web/20221205194635/https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2993.htm |archive-date=December 5, 2022 |date=2022-06-06 |url-status=live}}
Compiler support
The following compilers implement an experimental compiler flag to support this standard:
- GCC 9,{{cite web |title=GCC 9 Release Notes |url=https://gcc.gnu.org/gcc-9/changes.html#c |url-status=live |archive-url=https://web.archive.org/web/20221227032646/https://gcc.gnu.org/gcc-9/changes.html |archive-date=December 27, 2022 |website=GNU Project}}
- Clang 9.0,{{cite web |date=May 14, 2019 |title=Clang 9.0 - add new language mode for C2x |url=https://github.com/llvm/llvm-project/commit/d06f3917913d2558b771ccc48d838f8cd8993c01 |url-status=live |archive-url=https://web.archive.org/web/20221227032640/https://github.com/llvm/llvm-project/commit/d06f3917913d2558b771ccc48d838f8cd8993c01 |archive-date=December 27, 2022 |website=LLVM Project Repository}}
- Pelles C 11.00{{cite web |title=Pelles C - major changes between 10.00 and 11.00 |url=http://www.smorgasbordet.com/pellesc/changes_1000_1100.htm |url-status=live |archive-url=https://web.archive.org/web/20221227032644/http://www.smorgasbordet.com/pellesc/changes_1000_1100.htm |archive-date=December 27, 2022 |website=smorgasbordet.com}}
Available texts
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, dated 2023-04-01. In the months that followed this draft, hundreds of changes{{cite web |title=N3150 - Editor's Report, Post January-February 2023 Meeting |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3150.htm |website=open-std.org |date=2023-07-08}} were made before producing the working draft N3149 dated 2023-07-09 and the official draft standard N3219 dated 2024-02-22.{{cite web |title=N3221 - Editor's Report, Post January 2024 Meeting |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3221.htm |website=open-std.org |date=2024-02-15}} Neither of these later drafts are public.
On the same date that the draft standard N3219 was announced, a new working draft N3220{{cite web |title=ISO/IEC 9899:2024 (en) — N3220 working draft |url=https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf |website=open-std.org |date=2024-02-22}} was made public. While this document is officially described 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.
See also
References
{{Reflist}}
Further reading
- [https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf N3096] (last freely-available working draft before C23); WG14; April 2023. (free download)
- N3149 (working draft of C23 standard); WG14; July 2023. (not available to public)
- N3219 ([https://www.iso.org/standard/82075.html ISO/IEC 9899:2023 DIS Draft]); WG14; February 2024. (ISO draft available but not free)
- ISO/IEC 9899:2024 (official C23 standard); ISO; 2024. (planning for release in 2024)
- [https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf N3220] (first working draft after C23; differs from draft standard N3219 only in one footnote); WG14; February 2024. (free download)
External links
- [https://www.open-std.org/jtc1/sc22/wg14/ C Language WG14 (Working Group 14)]
:* [https://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log.htm WG14 Document Repository]
:* [https://www.open-std.org/jtc1/sc22/wg14/www/meetings WG14 Meetings] - agenda and minutes
:* WG14 Charters: [https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2021.htm C2x Charter], [https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2611.htm C23 Charter], [https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2986.htm Interpreting the C23 Charter], [https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3223.pdf C Standard Charter]
{{S-start}}
{{S-bef| before = C17}}
{{S-ttl| title=C language standards}}
{{S-non| reason=Latest}}
{{end}}
{{C programming language}}