C23 (C standard revision)

Last updated

C23 is the informal name for ISO/IEC 9899:2024, the next standard for the C programming language, which will replace C17 (standard ISO/IEC 9899:2018). [1] It was started in 2016 informally as C2x, [2] and expected to be published in 2024. [3] The most recent publicly available working draft of C23 was released on April 1, 2023. [4] 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.

Contents

Features

Changes integrated into the latest working draft of C23 are listed below. [4]

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. [6]
  • Add memccpy() function in <string.h> to efficiently concatenate strings – similar to POSIX and SVID C extensions. [7]
  • Add strdup() and strndup() functions in <string.h> to allocate a copy of a string – similar to POSIX and SVID C extensions. [8]
  • Add memalignment() function in <stdlib.h> to determine the byte alignment of a pointer. [9]
  • 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. [10]
    • In the following, replace * with uc, us, ui, ul, ull for five function names, or blank for a type-generic macro. [10]
    • Add stdc_count_ones*() and stdc_count_zeros*() to count number of 1 or 0 bits in value. [10]
    • Add stdc_leading_ones*() and stdc_leading_zeros*() to count leading 1 or 0 bits in value. [10]
    • Add stdc_trailing_ones*() and stdc_trailing_zeros*() to count trailing 1 or 0 bits in value. [10]
    • Add stdc_first_leading_one*() and stdc_first_leading_zero*() to find first leading bit with 1 or 0 in value. [10]
    • Add stdc_first_trailing_one*() and stdc_first_trailing_zero*() to find first trailing bit with 1 or 0 in value. [10]
    • 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). [10]
    • Add stdc_bit_floor*() to determine the largest integral power of 2 that is not greater than value. [10]
    • Add stdc_bit_ceil*() to determine the smallest integral power of 2 that is not less than value. [10]
    • Add stdc_bit_width*() to determine number of bits to represent a value. [10]
  • Add timegm() function in <time.h> to convert time structure into calendar time value - similar to function in glibc and musl libraries. [11]

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 did not use %B as their own extension are encouraged to implement and prepend non-zero values with 0B, similar to how %X works. [12]
  • Add %b binary conversion specifier to scanf() function family. [12]
  • Add 0b and 0B binary conversion support to strtol() and wcstol() function families. [12]
  • 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. [13]

Preprocessor

Types

Constants

Keywords

Syntax

C++ compatibility

Other features

Obsolete features

Some old obsolete features are either removed or deprecated from the working draft of C23:

  • Remove trigraphs. [59]
  • Remove K&R function definitions/declarations (with no information about the function arguments). [60] [61]
  • Remove representations for signed integers other than two's complement. Two's complement signed integer representation will be required. [62]
  • The *_HAS_SUBNORM macros in <float.h> are obsolescent features. [63]

Compiler support

The GCC 9, [64] Clang 9.0, [65] and Pelles C 11.00 [66] compilers implement an experimental compiler flag to support this standard.

See also

Related Research Articles

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 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 of the targeted CPUs. It has found lasting use in operating systems, 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.

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.

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.

<span class="mw-page-title-main">C99</span> C programming language standard, 1999 revision

C99 is an informal name for ISO/IEC 9899:1999, a past version of the C programming language 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 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 versions by the publication year of the specification, though it was formerly named C++0x because it was expected to be published before 2010.

This article compares a large number of programming languages by tabulating their data types, their expression, statement, and declaration syntax, and some common operating-system interfaces.

In computer science, manifest typing is explicit identification by the software programmer of the type of each variable being declared. For example: if variable X is going to store integers then its type must be declared as integer. The term "manifest typing" is often used with the term latent typing to describe the difference between the static, compile-time type membership of the object and its run-time type identity.

C11 is an informal name for ISO/IEC 9899:2011, 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.

<span class="mw-page-title-main">Rust (programming language)</span> General-purpose programming language

Rust is a multi-paradigm, general-purpose programming language that emphasizes performance, type safety, and concurrency. It enforces memory safety—meaning that all references point to valid memory—without a garbage collector. To simultaneously enforce memory safety and prevent data races, its "borrow checker" tracks the object lifetime of all references in a program during compilation. Rust was influenced by ideas from functional programming, including immutability, higher-order functions, and algebraic data types. It is popular for systems programming.

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 is the informal name for ISO/IEC 9899:2018, the most recent standard for the C programming language, prepared in 2017 and published in June 2018. It replaced C11, and will be superseded by C23 when it is published in 2024. Since it was under development in 2017, and officially published in 2018, C17 is sometimes referred to as C18.

C++23 is the informal name for the version of the ISO/IEC 14882 standard for the C++ programming language that followed C++20. The final draft of this version is N4950.

References

  1. "History of C". cppreference.com. 2022-06-27. Archived from the original on October 19, 2022.
  2. "WG14-N2086 : C2x Charter". open-std.org. 2016-09-20. Archived from the original on December 22, 2022.
  3. "WG14-N3156 : Updated C23 Schedule" (PDF). open-std.org. 2023-07-19. Archived (PDF) from the original on January 29, 2024.
  4. 1 2 "WG14-N3096 : Draft for ISO/IEC 9899:2024" (PDF). open-std.org. April 1, 2023. Archived (PDF) from the original on April 2, 2023.
  5. "WG14-N2437 : Agenda for October 2019". open-std.org. 2019-10-21. Archived from the original on March 5, 2021.
  6. "WG14-N2897 : memset_explicit()". open-std.org. 2021-12-27. Archived from the original on October 25, 2022.
  7. "WG14-N2349 : Toward more efficient string copying and concatenation". open-std.org. 2019-03-18. Archived from the original on September 30, 2022.
  8. "WG14-N2353 : strdup() and strndup()". open-std.org. 2019-03-18. Archived from the original on December 24, 2022.
  9. "WG14-N2974 : Queryable pointer alignment" (PDF). open-std.org. 2022-04-15. Archived (PDF) from the original on October 13, 2022.
  10. 1 2 3 4 5 6 7 8 9 10 11 "WG14-N3022 : Modern Bit Utilities". open-std.org. 2022-07-06. Archived from the original on December 24, 2022.
  11. "WG14-N2833 : Add timegm() as non-optional part of time.h". open-std.org. 2021-10-07. Archived from the original on December 1, 2021.
  12. 1 2 3 "WG14-N2630 : formatted input/output of binary integer numbers" (PDF). open-std.org. 2021-01-01. Archived (PDF) from the original on December 14, 2022.
  13. "WG14-N3020 : Qualifier-preserving standard library functions" (PDF). open-std.org. 2022-06-13. Archived (PDF) from the original on October 13, 2022.
  14. 1 2 "WG14-N2645 : Add support for preprocessing directives #elifdef and #elifndef" (PDF). open-std.org. 2020-01-25. Archived (PDF) from the original on November 28, 2022.
  15. "GCC 12 Adds Support For New #elifdef #elifndef Directives". phoronix. May 12, 2021. Archived from the original on December 27, 2022.
  16. "WG14-N3017 : #embed - a scannable, tooling-friendly binary resource inclusion mechanism". open-std.org. 2022-06-27. Archived from the original on December 24, 2022.
  17. "WG14-N2686 : #warning" (PDF). open-std.org. 2022-07-22. Archived (PDF) from the original on November 28, 2022.
  18. "WG14-N2799 : __has_include for C" (PDF). open-std.org. 2021-08-30. Archived (PDF) from the original on December 24, 2022.
  19. "WG14-N2553 : Querying attribute support" (PDF). open-std.org. 2020-08-04. Archived (PDF) from the original on October 14, 2022.
  20. "WG14-N3033 : Comma omission and comma deletion". open-std.org. 2022-07-20. Archived from the original on December 27, 2022.
  21. 1 2 "WR14-N3042 : Introduce the nullptr constant". open-std.org. 2022-07-22. Archived from the original on December 24, 2022.
  22. "WG14-N2763 : Adding a Fundamental Type for N-bit integers" (PDF). open-std.org. 2021-06-21. Archived (PDF) from the original on December 27, 2022.
  23. "WG14-N3035 : _BitInt Fixes" (PDF). open-std.org. 2022-07-21. Archived (PDF) from the original on October 13, 2022.
  24. "WG14-N2867 : Checked N-Bit Integers" (PDF). open-std.org. 2021-11-28. Archived (PDF) from the original on December 14, 2022.
  25. "WG14-N2778 : Variably-Modified Types" (PDF). open-std.org. 2021-07-11. Archived (PDF) from the original on December 22, 2022.
  26. "WG14-N2607 : Compatibility of Pointers to Arrays with Qualifiers" (PDF). open-std.org. 2020-10-31. Archived (PDF) from the original on October 13, 2022.
  27. "WG14-N2899 : Not-so-magic - typeof for C". open-std.org. 2022-01-21. Archived from the original on December 24, 2022.
  28. "WG14-N3007 : Type inference for object definitions". open-std.org. 2022-06-10. Archived from the original on December 24, 2022.
  29. "WG14-N3037 : Improved Rules for Tag Compatibility (updates N3032)" (PDF).
  30. "WG14-N2775 : Literal suffixes for bit-precise integers" (PDF). open-std.org. 2021-07-13. Archived (PDF) from the original on December 27, 2022.
  31. "WG14-N2549 : Allow for binary integer constants" (PDF). open-std.org. 2020-07-30. Archived (PDF) from the original on December 22, 2022.
  32. "WG14-N2626 : Digit separators" (PDF). open-std.org. 2020-12-15. Archived (PDF) from the original on December 19, 2022.
  33. "WG14-N3030 : Enhancements to Enumerations". open-std.org. 2022-07-19. Archived from the original on November 26, 2022.
  34. "WG14-N3029 : Improved Normal Enumerations". open-std.org. 2022-07-19. Archived from the original on January 29, 2023.
  35. "WG14-N2935 : Make false and true first-class language features" (PDF). open-std.org. 2022-02-15. Archived (PDF) from the original on November 21, 2022.
  36. "WG14-N2934 : Revise spelling of keywords" (PDF). open-std.org. 2022-02-15. Archived (PDF) from the original on December 24, 2022.
  37. "WG14-N2508 : Free Positioning of Labels Inside Compound Statements" (PDF). open-std.org. 2020-03-28. Archived (PDF) from the original on December 27, 2022.
  38. "WG14-N2510 : Allowing unnamed parameters in a function definition" (PDF). open-std.org. 2020-04-09. Archived (PDF) from the original on December 24, 2022.
  39. "WG14-N2900 : Consistent, Warningless, and Intuitive Initialization with {}". open-std.org. 2022-01-01. Archived from the original on December 27, 2022.
  40. "WG14-N2975 : Relax requirements for variadic parameter lists" (PDF). open-std.org. 2022-04-15. Archived (PDF) from the original on November 28, 2022.
  41. "WG14-N2335 : Attributes in C" (PDF). open-std.org. 2019-03-09. Archived (PDF) from the original on October 26, 2022.
  42. "WG14-N2265 : Harmonizing static_assert with C++" (PDF). open-std.org. 2018-07-06. Archived (PDF) from the original on March 28, 2023.
  43. "Labels at the end of compound statements (C compatibility)" (PDF). 2022-01-13.
  44. "WG14-N2554 : Minor attribute wording cleanups" (PDF). open-std.org. 2020-08-04. Archived (PDF) from the original on November 28, 2022.
  45. "WG14-N2334 : The deprecated attribute" (PDF). open-std.org. 2019-01-22. Archived (PDF) from the original on October 19, 2022.
  46. "WG14-N2408 : The fallthrough attribute" (PDF). open-std.org. 2019-08-11. Archived (PDF) from the original on December 25, 2022.
  47. "WG14-N2270 : The maybe_unused attribute" (PDF). open-std.org. 2018-07-06. Archived (PDF) from the original on December 25, 2022.
  48. "WG14-N2267 : The nodiscard attribute" (PDF). open-std.org. 2018-07-06. Archived (PDF) from the original on October 19, 2022.
  49. "WG14-N2764 : The noreturn attribute" (PDF). open-std.org. 2021-06-21. Archived (PDF) from the original on December 25, 2022.
  50. "WG14-N2557 : Allow Duplicate Attributes" (PDF). open-std.org. 2020-09-01. Archived (PDF) from the original on November 28, 2022.
  51. "WG14-N2418 : Adding the u8 character prefix" (PDF). open-std.org. 2019-09-02. Archived (PDF) from the original on January 13, 2023.
  52. What is the point of the UTF-8 character literals proposed for C++17?; Stack Overflow.
  53. "WG14-N2341 : ISO/IEC TS 18661-2 - Floating-point extensions for C - Part 2: Decimal floating-point arithmetic" (PDF). open-std.org. February 26, 2019. Archived (PDF) from the original on November 21, 2022.
  54. "WG14-N2601 : Annex X - IEC 60559 interchange and extended types" (PDF). open-std.org. October 15, 2020. Archived (PDF) from the original on October 14, 2022.
  55. "WG14-N3018 : The constexpr specifier for object definitions". open-std.org. 2022-07-06. Archived from the original on December 24, 2022.
  56. "WG14-N2653 : char8_t: A type for UTF-8 characters and strings (Revision 1)". open-std.org. 2021-06-04. Archived from the original on May 27, 2023.
  57. "WG14-N2728 : char16_t & char32_t string literals shall be UTF-16 & UTF-32". open-std.org. 2021-05-15. Archived from the original on May 27, 2023.
  58. "WG14-N3038 : Introduce storage-class specifiers for compound literals". open-std.org. 2022-07-21. Archived from the original on November 26, 2022.
  59. "WG14-N2940 : Removing trigraphs??!" (PDF). open-std.org. 2022-03-02. Archived (PDF) from the original on October 26, 2022.
  60. "WG14-N2432 : Remove support for function definitions with identifier lists proposal" (PDF). open-std.org. September 25, 2019. Archived (PDF) from the original on December 27, 2022.
  61. "WG14-N2841 : No function declarators without prototypes". open-std.org. 2021-10-10. Archived from the original on November 12, 2022.
  62. "WG14-N2412 : Two's complement sign representation" (PDF). open-std.org. August 11, 2019. Archived (PDF) from the original on December 27, 2022.
  63. "WG14-N2993 : Make *_HAS_SUBNORM be obsolescent". open-std.org. 2022-06-06. Archived from the original on December 5, 2022.
  64. "GCC 9 Release Notes". GNU Project. Archived from the original on December 27, 2022.
  65. "Clang 9.0 - add new language mode for C2x". LLVM Project Repository. May 14, 2019. Archived from the original on December 27, 2022.
  66. "Pelles C - major changes between 10.00 and 11.00". smorgasbordet.com. Archived from the original on December 27, 2022.

Further reading

Preceded by
C17
C language standards Latest