Major Revisions to the 5th Edition of C (C23)
This information is copied verbatim from Annex M.2 of ISO/IEC 9899:2024. This information is copyright ISO 2024— All rights reserved.
Major changes in the fifth edition of the C Programming Language Standard (__STDC_VERSION__ 202311L) include:
— add new keywords such as bool, static_assert, true, false, thread_local and others, and allowed implementations to provide macros for the older spelling with a leading underscore followed by a capital letter as well as defining old and new keywords as macros to enable transition of programs easily;
— removed integer width constraints and obsolete sign representations (so-called "1’s complement" and "sign-magnitude");
— added a one-argument version of static_assert;
— removed support for function definitions with identifier lists;
— mandated function declarations whose parameter list is empty be treated the same as a parameter list which only contain a single void;
— harmonization with ISO/IEC 9945 (POSIX):
? extended month name formats for strftime
? integration of functions: gmtime_r, localtime_r, memccpy, strdup, strndup
— harmonization with floating-point standard ISO/IEC 60559:
? integration of binary floating-point technical specification TS 18661-1
? integration of decimal floating-point technical specification TS 18661-2
? integration of floating-point types technical specification TS 18661-3
? integration of mathematical functions technical specification TS 18661-4a
? new maximum and minimum functions for operations recommended in
ISO/IEC 60559:2020
— made the DECIMAL_DIG macro obsolescent;
— added version test macros to library headers that contained changes to aid in upgrading and portability to be used alongside the __STDC_VERSION__ macro;
— allowed placement of labels in front of declarations and at the end of compound statement;
— added the attributes feature, which includes the attributes:
? deprecated, for marking entities as discouraged for future use;
? fallthrough, for explicitly marking cases where falling through in switches or labels is intended rather than accidental;
? maybe_unused, for marking entities which may end up not being used;
? nodiscard, for marking entities which, when used, should have their value handled in some way by a program;
? noreturn, for indicating a function shall never return;
? reproducible, for marking function types for which inputs may always produce predictable output if given the same input (e.g. cached data) but for which the order of such calls still matter; and,
? unsequenced, for marking function types which always produce predictable output and have no dependencies upon other data (and other relevant caveats);
— added the u8 character prefix to match the u8 string prefix;
— mandated all u8, u, and U strings be UTF-8, UTF-16, and UTF-32, respectively, as defined by ISO/IEC 10646;
— separated the literal, wide literal, and UTF-8 literal, UTF-16 literal, and UTF-32 literal encodings for strings and characters and now have a solely execution-based version of these, particularly execution and wide execution encodings;
— added mbrtoc8 and c8rtomb functions missing from <uchar.h>;
— compound literals may also include storage-class specifiers as part of the type to change the lifetime of the compound literal (and possibly turn it into a constant expression)
— added the constexpr specifier for object definitions and improved what is recognized as a constant expression in conjunction with the constexpr storage-class specifier;
— added support for initialization of objects with empty braces;
— added the typeof and typeof_unqual operations for deducing the type of an expression;
领英推荐
— improved tag compatibility rules, enabling more types to be compatible with other types;
— added bit-precise integer types BitInt( N) and unsigned BitInt( N), where N can be an integer constant expression whose value is from one to BITINT_MAXWIDTH, inclusive.
— improved rules for handling enumerations without underlying types, in particular allowing for enumerations without fixed underlying type to have value representations that have a greater range than int;
— added a new colon-delimited type specifier for enumerations to specify a fixed underlying type (and which, subject to an implementation’s definitions governing such constructs, adopt the fixed underlying type’s rules for padding, alignment, and sizing within structures and unions as well as with bit-fields);
— added a new header <stdbit.h> and a suite of bit and byte-handling utilities for portable access to many implementations’ most efficient functionality;
— modified existing functions to preserve the const-ness of the type placed into the function;
— added a feature to embed binary data as faithfully as possible with a new preprocessor directive #embed;
— added a nullptr constant and a nullptr_t type with a well-defined underlying representation identical to a pointer to void;
— added the __VA_OPT__ specifier and clarified language in the handling of macro invocation and arguments;
— mandated support for variably modified types (but not variable length arrays themselves);
— parameter names may be omitted in function definitions;
— ellipses on functions may appear without a preceding parameter in the parameter list of functions and va_start no longer requires such an argument to be passed to it;
— Unicode identifiers allowed in syntax following Unicode Standard Annex, UAX #31;
— added the memset_explicit function for making sensitive information inaccessible;
— added memalignment function to query the alignment of a pointer;
— certain type definitions (i.e. exact-width integer types such as int128_t), bit-precise integer types, and extended integer types may exceed the normal boundaries of intmax_t and uintmax_t for signed and unsigned integer types, respectively;
— names of functions, macros, and variables in this document, where clarified, are potentially reserved rather than reserved to avoid undefined behavior for a large class of identifiers used by programs existing and to be created;
— mandated support for call_once;
— allowed ptrdiff_t to be an integer type with a width of at least 16, rather than requiring an integer type with a width of at least 17;
— added the __has_include feature for conditional inclusion expression preprocessor directives to check if a header is available for inclusion;
— changed the type qualifiers of the ImaginaryI and ComplexI macros;
— added qualifier preserving macros for bsearch, memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr;
— added (U+0040, COMMERCIAL AT), $ (U+0024, DOLLAR SIGN), and ` (U+0060, GRAVE ACCENT, "Backtick") into the source and execution character set;
— enhanced the auto type specifier for single object definitions using type inference;
— added the #elifdef and #elifndef conditional inclusion preprocessor directives;
— added the #warning preprocessing directive;
— binary integer literals and appropriate formatting for input/output of binary integer numbers;
— digit separators with ’ (single quotation mark);
— removed conditional support for mixed wide and narrow string literal concatenation;
— added support for additional time bases, as well as timespec_getres, in <time.h>;
— added support for new interface timegm to retrieve the broken-down time, in <time.h>;
— zero-sized reallocations with realloc are undefined behavior;
— added free_sized and free_aligned_sized functions;
— added an unreachable feature which has undefined behavior if reached during program execution;
— added printf and scanf length modifiers for intN_t, int_fastN_t, uintN_t, and uint_fastN_t.
Concepteur logiciel chez NGC Aérospatiale
4 个月Constexpr specifier, unsequenced and noreturn attributes, typeof operation and many others features are great additions for embedded systems!
Director, Data Product Management, Digital Protection at Walmart
8 个月The C23 update brings a new function for securely clearing sensitive data, a step forward in making the C language more secure and privacy-conscious. Nice.
Staff Software Architect at Entrust Data Protection Solutions
9 个月Some good stuff in there - thankyou to you and everyone who worked on it.
Senior Principal Applied Scientist, Amazon Web Services
9 个月Thanks