C2x is an informal name for the next (after
C17) major
C language
C (''pronounced like the letter c'') is a general-purpose computer 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 o ...
standard revision.
It is expected to be voted on in 2023 and would therefore become C23.
The most recent publicly available draft of C23 was released on January 24, 2023.
The first WG14 meeting for the C2x draft was held in October 2019, then virtual remote meetings were held due to
COVID-19 pandemic
The COVID-19 pandemic, also known as the coronavirus pandemic, is an ongoing global pandemic of coronavirus disease 2019 (COVID-19) caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The novel virus was first identified ...
in March/April 2020, October/November 2020, March/April 2021, August/September 2021, November/December 2021, January/February 2022, May 2022, July 2022, January 2023.
Features
Changes integrated into the latest C23 draft are:
;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.
:* add
memccpy()
function in
to efficiently concatenate strings - similar to
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inte ...
and
SVID C extensions.
:* add
strdup()
and
strndup()
functions in
to allocate a copy of a string – similar to
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inte ...
and
SVID C extensions.
:* add
memalignment()
function in
< stdlib.h>
to determine the byte alignment of a pointer.
:* add bit utility functions / macros / types in new header
< stdbit.h>
to examine many integer types. All start with
stdc_
to minimize conflict with legacy code and 3rd party libraries.
:** In the following, replace
*
with
uc
,
us
,
ui
,
ul
,
ull
for five function names, or blank for a type-generic macro.
:** add
stdc_count_ones*()
and
stdc_count_zeros*()
to count number of 1 or 0 bits in value.
:** add
stdc_leading_ones*()
and
stdc_leading_zeros*()
to count leading 1 or 0 bits in value.
:** add
stdc_trailing_ones*()
and
stdc_trailing_zeros*()
to count trailing 1 or 0 bits in value.
:** add
stdc_first_leading_one*()
and
stdc_first_leading_zero*()
to find first leading bit with 1 or 0 in value.
:** add
stdc_first_trailing_one*()
and
stdc_first_trailing_zero*()
to find first trailing bit with 1 or 0 in value.
:** add
stdc_has_single_bit*()
to determine if value 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.
;Standard Library (existing functions)
:* add
%b
binary conversion specifier to
printf()
function family, prepending non-zero values with
0b
, similar to how
%x
works. Implementations that previously didn't use
%B
as their own extension are encouraged to implement and prepend non-zero values with
0B
, similar to how
%X
works.
:* add
%b
binary conversion specifier to
scanf()
function family.
:* add
0b
and
0B
binary conversion support to
strtol()
and
wcstol()
function families.
:* make the functions
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.
;Preprocessor
:* add and
directives are essentially equivalent to and . Both directives were added to
C++23 C23 or C-23 may refer to:
Vehicles
;Aircraft
* Beechcraft C23 Musketeer, an American civil utility aircraft
* Caspar C 23, a German sport aircraft
* Caudron C.23, a French bomber biplane
* Lockheed C-23 Altair, an American military transport
* Sh ...
and
GCC 12 too.
:* add directive for binary resource inclusion.
:* add directive for diagnostics.
:* add allowing the availability of a header to be checked by preprocessor directives.
:* add allowing the availability of an attribute to be checked by preprocessor directives.
(see C++ compatibility group below for new attribute feature)
:* add functional macro for
variadic macro
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.
Variable-argument macros were introduced in 1999 in the ''ISO/IEC 989 ...
s which expands to its argument only if a variadic argument has been passed to the containing macro.
;Types
:* add type.
:* add and types for bit-precise integers. Add macro for maximum bit width.
Add
ckd_add()
,
ckd_sub()
,
ckd_mul()
macros for checked integer operations.
:* Variably-modified types (but not
VLAs which are
automatic variables allocated on the stack) become a mandatory feature.
:* Standardization of the
typeof
typeof, alternately also typeOf, and TypeOf, is an operator provided by several programming languages to determine the data type of a variable. This is useful when constructing programs that must accept multiple types of data without explicitly sp ...
(...)
operator.
:* the meaning of the keyword was changed to cause
type inference
Type inference refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some branches of computer science and linguistics. ...
while also retaining its old meaning of a
storage class specifier
Storage may refer to:
Goods Containers
* Dry cask storage, for storing high-level radioactive waste
* Food storage
* Intermodal container, cargo shipping
* Storage tank
Facilities
* Garage (residential), a storage space normally used to store ca ...
if used alongside a type.
;Constants
:* add
constant for
nullptr_t
type.
:* add
wb
and
uwb
integer literal suffixes for and types,
such as yields an
unsigned _BitInt(3)
, and yields a
signed _BitInt(4)
which has three value bits and one sign bit.
:* add
0b
and
0B
binary literal constant prefixes,
such as (equating to 0xAA).
:* add
'
digit separator to literal constants,
such as (equating to 0xFEDCBA98), (equating to
299792458), (equating to
1.414213562).
:* add the ability to specify the underlying type of an
enum
Telephone number mapping is a system of unifying the international telephone number system of the public switched telephone network with the Internet addressing and identification name spaces. Internationally, telephone numbers are systematicall ...
.
;C++ compatibility
:* add
C++11
C++11 is a version of the ISO/ IEC 14882 standard for the C++ programming language. C++11 replaced the prior version of the C++ standard, called C++03, and was later replaced by C++14. The name follows the tradition of naming language versio ...
style
attribute syntax
using double square brackets . Add attributes
,
,
,
and attribute for compatibility with
C++11
C++11 is a version of the ISO/ IEC 14882 standard for the C++ programming language. C++11 replaced the prior version of the C++ standard, called C++03, and was later replaced by C++14. The name follows the tradition of naming language versio ...
, then deprecate , , header
features introduced in
C11 C11, C.XI, C-11 or C.11 may refer to:
Transport
* C-11 Fleetster, a 1920s American light transport aircraft for use of the United States Assistant Secretary of War
* Fokker C.XI, a 1935 Dutch reconnaissance seaplane
* LET C-11, a license-build var ...
.
Duplicate attributes are allowed for compatility with
C++23 C23 or C-23 may refer to:
Vehicles
;Aircraft
* Beechcraft C23 Musketeer, an American civil utility aircraft
* Caspar C 23, a German sport aircraft
* Caudron C.23, a French bomber biplane
* Lockheed C-23 Altair, an American military transport
* Sh ...
.
:* add
u8
prefix for
character literal A character literal is a type of literal in programming for the representation of a single character's value within the source code of a computer program.
Languages that have a dedicated character data type generally include character literals; th ...
s to represent
UTF-8
UTF-8 is a variable-length character encoding used for electronic communication. Defined by the Unicode Standard, the name is derived from ''Unicode'' (or ''Universal Coded Character Set'') ''Transformation Format 8-bit''.
UTF-8 is capable of ...
encoding for compatibility with
C++17
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.
History
Before the C++ Standards Committee fixed a 3-yea ...
.
:* add and preprocessing directives for compatibility with
C++23 C23 or C-23 may refer to:
Vehicles
;Aircraft
* Beechcraft C23 Musketeer, an American civil utility aircraft
* Caspar C 23, a German sport aircraft
* Caudron C.23, a French bomber biplane
* Lockheed C-23 Altair, an American military transport
* Sh ...
.
(see preprocessor group above)
;Other
:* 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.
:* Single-argument
_Static_assert
.
:*
Labels
A label (as distinct from signage) is a piece of paper, plastic film, cloth, metal, or other material affixed to a container or product, on which is written or printed information or symbols about the product or item. Information printed dir ...
can appear before
declarations and at the end of
compound statements.
:* Unnamed parameters in function definitions.
:* Better support for using
const
In some programming languages, const is a type qualifier (a keyword applied to a data type) that indicates that the data is read-only. While this can be used to declare constants, in the C family of languages differs from similar constructs i ...
with arrays.
:* Zero initialization with
(including initialization of VLAs).
:* , , , , , ,
become keywords.
:* The
constexpr
C++11 is a version of the ISO/ IEC 14882 standard for the C++ programming language. C++11 replaced the prior version of the C++ standard, called C++03, and was later replaced by C++14. The name follows the tradition of naming language versio ...
specifier for objects but not functions, unlike
C++'s equivalent.
:*
variadic functions no longer need a named argument before the ellipsis and the macro no longer needs a second argument nor does it evaluate any argument after the first one if present.
:* add the type for storing
UTF-8
UTF-8 is a variable-length character encoding used for electronic communication. Defined by the Unicode Standard, the name is derived from ''Unicode'' (or ''Universal Coded Character Set'') ''Transformation Format 8-bit''.
UTF-8 is capable of ...
encoded data and change the type of u8 character constants and string literals to . 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.
:* allow
storage class specifier
Storage may refer to:
Goods Containers
* Dry cask storage, for storing high-level radioactive waste
* Food storage
* Intermodal container, cargo shipping
* Storage tank
Facilities
* Garage (residential), a storage space normally used to store ca ...
s to appear in compound literal definition.
Obsolete features
Some old obsolete features are either removed or deprecated:
:* Remove
Trigraphs.
:* Remove
K&R function definitions/declarations.
:* Remove representations for signed integers other than two's complement.
Two's complement
Two's complement is a mathematical operation to reversibly convert a positive binary number into a negative binary number with equivalent (but negative) value, using the binary digit with the greatest place value (the leftmost bit in big- endian ...
signed integer representation will be required.
:* The macros in
are obsolescent features.
Compiler support
The
GCC 9,
Clang
Clang is a compiler front end for the C, C++, Objective-C, and Objective-C++ programming languages, as well as the OpenMP, OpenCL, RenderScript, CUDA, and HIP frameworks. It acts as a drop-in replacement for the GNU Compiler Collection ...
9.0, and
Pelles C 11.00
compilers implement an experimental compiler flag to support this standard.
See also
*
C++23 C23 or C-23 may refer to:
Vehicles
;Aircraft
* Beechcraft C23 Musketeer, an American civil utility aircraft
* Caspar C 23, a German sport aircraft
* Caudron C.23, a French bomber biplane
* Lockheed C-23 Altair, an American military transport
* Sh ...
,
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. The standard was technically finalized by WG21 at the meeting in Prague in February 2020 ...
,
C++17
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.
History
Before the C++ Standards Committee fixed a 3-yea ...
,
C++14
C14, C.XIV or C-14 may be:
* Autovía C-14, a highway in Catalonia in Spain
* Fokker C.XIV, a 1937 Dutch reconnaissance seaplane
* , a 1908 British C-class submarine
* LSWR C14 class, a London and South Western Railway locomotive
* Ramal C-14, th ...
,
C++11
C++11 is a version of the ISO/ IEC 14882 standard for the C++ programming language. C++11 replaced the prior version of the C++ standard, called C++03, and was later replaced by C++14. The name follows the tradition of naming language versio ...
,
C++03
C, or c, is the third letter in the Latin alphabet, used in the modern English alphabet, the alphabets of other western European languages and others worldwide. Its name in English is ''cee'' (pronounced ), plural ''cees''.
History
"C" ...
,
C++98 C98 or C-98 may refer to:
* C-98 Clipper, the military designation of the Boeing 314 flying boat
* CJYC-FM, "Big John FM", formerly known as "C98"
* Cray C98, a model of the Cray C90
* Ruy Lopez
The Ruy Lopez (; ), also called the Spanish ...
, versions of the C++ programming language standard
*
Compatibility of C and C++
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 th ...
References
External links
C Working Group WG14 DocumentsN3088, draft of C23 standard (January 2023)
{{C programming language
C (programming language)
Programming language standards