YOUR C LEARNING COMPANION

Find your next idea.

Learning path
C in contextChapter 71 of 73

Modern C: C23 features and adoption

Understand C23’s language and library changes, remaining contracts, and feature-by-feature implementation support.

9 min readIntermediateC23 · support varies
Offline reading
In this chapter11 sections

C23 adds useful language and library facilities. Before using one, check what the feature means and whether your compiler and library support it. We will keep new capabilities separate from the bounds, lifetime, and argument rules they still require.

The examples marked C23 require the corresponding language and library facilities. They are separate from this reader’s C17 baseline. A feature illustration is not a promise that every installed compiler or target supports the entire revision.

1. Published revision, selected mode, and actual support

As checked on 31 October 2026, WG14 lists C23 as published and the next main revision, C2y, as unpublished. Newer proposals and separate technical specifications do not silently become C23. Consult the standards timeline when a draft’s year and a revision nickname differ.

Implementation support has several layers: compiler language mode/version, target, supplied headers, linked library, and runtime environment. Compiler support tables track facilities separately. An older compiler’s preview mode can accept some final C23 forms without implementing them all; a newer compiler flag still does not inventory every optional library feature.

2. New spellings and named constant objects

bool, true, false, alignas, alignof, static_assert, and thread_local are C23 language spellings. The five older underscored alternatives remain recognized but are obsolescent. nullptr is a predefined null-pointer constant; stddef.h supplies the type name nullptr_t. Neither nullptr_t nor NULL is another language keyword.

C23 · feature example (support required)
#include <assert.h>
#include <stddef.h>

constexpr int capacity = 4;
static_assert(capacity == 4);

int main(void)
{
    auto count = capacity;
    bool ready = true;
    int *cursor = nullptr;
    assert(count == 4 && ready && cursor == nullptr);
    return 0;
}

constexpr supplies a named constant object under constrained initialization rules. auto infers a fixed type from its supported initializer form; it does not create a dynamically typed variable. This is not C++ constexpr-function support or permission to use every C++ auto declaration. The constant-expression lesson and keyword index give the connected rules.

nullptr’s own type is distinct from pointer types. Variadic functions still have argument-type contracts. For examples shared between C17 and C23, explicitly convert an object pointer to void * before a %p conversion; do not assume every null-looking value fits every variadic API. A null pointer also does not describe a character terminator or an all-zero representation.

3. Types, qualifications, and bit-precise values

C23 · feature example (support required)
#include <assert.h>

int main(void)
{
    const int original = 7;
    typeof_unqual(original) editable = original;
    typeof(original) *reader = &original;
    editable += 1;
    assert(editable == 8 && *reader == 7);
    return 0;
}

typeof derives a type from a type name or expression. typeof_unqual removes top-level and atomic qualification, so editable here is a mutable int while reader points to const int. It does not strip a pointed-to const. Ordinary operands are unevaluated, but variably modified types introduce evaluation cases; “typeof never evaluates anything” is too broad.

Optional: bit-precise value width, not promised storage size
C23 · feature example (support required)
#include <assert.h>

int main(void)
{
    unsigned _BitInt(9) flags = 0x1FF;
    flags += 1;
    assert(flags == 0);
    return 0;
}

Unsigned _BitInt(9) represents values from 0 through 511. Conversion back to that unsigned type gives the modular result 0 here. For signed _BitInt(N), N includes the sign bit and must be at least 2 (unsigned N can start at 1); implementations specify a supported maximum through BITINT_MAXWIDTH. The requested value width is not a promise that sizeof reports exactly N storage bits. Layout, rank/conversion rules, and supported targets still matter.

C23 also extends enumeration facilities, including explicit underlying-type forms and broader enumerator handling. Decimal floating types are conditional facilities. Use enumeration rules and actual implementation documentation rather than assuming all new type names are universally available.

4. Function declarations, initialization, and source notation

ChangeMeaningBoundary
Empty function parameter listIn a C23 declaration, int f(); is a prototype for no parameters.In a C17 declaration it supplies no parameter-type information. int f(void) is explicit in both.
Old identifier-list definitionsThe old K&R definition form is removed.Use typed parameter declarations; do not copy historical syntax as current teaching style.
Empty initializer {}Permitted forms perform empty initialization under the object/type rules.Typed zero initialization is not a universal all-zero byte-format promise.
Binary literals and digit separators0b101010 and 1'000'000 improve notation.A clearer literal does not change its range/type/conversion obligations.
#elifdef / #elifndef / #warningAdditional conditional and diagnostic preprocessing facilities.Preprocessing remains distinct from runtime control flow.
#embedExpands a resource into integer-constant tokens during preprocessing.It is not a runtime file-read API; resource and implementation limits apply.

See function contracts, initialization, and preprocessing for context. Standard attributes such as [[nodiscard]], [[maybe_unused]], and [[fallthrough]] have individual rules. Others, including [[noreturn]] and function-property attributes, assert semantic contracts. Standard attributes may be ignored without changing a correct program’s semantics; a false asserted property can make the program invalid or lead to undefined behavior. They are not a general warning-suppression or correctness switch.

5. Library additions: checked arithmetic and bit utilities

Checked arithmetic from <stdckdint.h> helps detect whether an integer result is representable. Check the returned failure flag before accepting the destination value; do not use an overflowed result as if it were the mathematical answer.

C23 · feature example (support required)
#include <assert.h>
#include <limits.h>
#include <stdckdint.h>

int main(void)
{
    int candidate = 0;
    bool overflow = ckd_add(&candidate, INT_MAX, 1);
    assert(overflow);
    bool fits = !ckd_add(&candidate, 40, 2);
    assert(fits && candidate == 42);
    return 0;
}

The first operation reports overflow, and the example does not inspect that result value. The second operation fits and produces 42. This differs from evaluating an overflowing ordinary signed addition first and hoping a later comparison repairs it.

<stdbit.h> adds bit utilities. This example counts the two set bits in the unsigned argument 0xA0; use each facility’s specified type and zero-input rules.

C23 · feature example (support required)
#include <assert.h>
#include <stdbit.h>

int main(void)
{
    unsigned count = stdc_count_ones(0xA0u);
    assert(count == 2);
    return 0;
}

Other library additions include strdup/strndup for allocated copies (check allocation failure and release with free), memset_explicit for an overwrite that must not be optimized away under its contract, and free_sized/free_aligned_sized for deallocation with required allocation metadata. An explicit wipe is not proof that every secret copy disappeared; a sized free is not permission to guess the original size or alignment. A header’s presence, a feature-test macro, or a successful parser check alone is not proof of a complete usable runtime implementation.

6. New representation rules do not remove old obligations

C23 requires two’s-complement representation for the standard signed integer types. Ordinary signed arithmetic overflow remains undefined. Negative signed right shift and an unrepresentable conversion to a signed integer type retain their specified implementation choices. Pointer bounds, access types, lifetimes, and synchronization contracts also continue to apply.

For a non-null pointer, C23 makes a zero-size realloc request undefined behavior. The separate null-pointer branch follows malloc’s zero-size rules; do not collapse the two cases into one slogan. A clear application policy handles release explicitly with free and avoids using a zero-size realloc request as a portable release operation.

7. Review an adoption as a small engineering change

Choose a supported mode and target; confirm the particular feature and library; compile a minimal example; test the real interface and failure paths; and keep a C17 alternative when that is a project requirement. A compiler accepting one extension does not update your team’s portability contract.

Preserve ownership and valid-input assumptions while changing syntax. Review removed/deprecated forms, warning policy, build flags for every translation unit, headers, and dependent libraries. Document the selected baseline so another learner can reproduce the program rather than guessing which “modern C” was intended.

8. Thought check: is two’s-complement signed wrap now safe?

The representation is two’s complement. May an ordinary signed increment overflow and then be checked?

No. Representation and arithmetic validity are different rules. Prove the operation fits before performing it, use an appropriate checked facility where supported, or choose a deliberately modular unsigned domain.

Sources and further reading

Before you move on

  • C23 adds language and library features with their own contracts.
  • Compiler support, library support, and target availability are separate checks.
  • New syntax does not remove bounds, lifetime, range, or argument-type requirements.
Keep these ideas separate
Language mode / Complete support
Selecting a C23 mode does not establish that every language and library facility is implemented on the target.
Explain it in your own words

How would you verify a new C23 facility before depending on it in a program intended for several toolchains?

Optional: say it aloud or keep a note. You can continue whenever you are ready.

Check your understanding

Optional. Answers are not saved or sent, and reading stays unrestricted.

Before relying on a C23 feature, what should you check?
Read the explanation for every choice
  1. Only that the source file ends in .c.

    The extension alone establishes neither a language edition nor feature support.

  2. That one unrelated C23 example compiled.

    Support for one feature does not prove support for every language and library change.

  3. The selected language mode and actual compiler/library support for the feature.

    ✓ Correct reasoning. Language editions and implementation support are distinct. Use documented support and a relevant feature check where appropriate.

C23 adoption

Quick reference from the earlier edition

Retained for existing section links and saved passages. Exact corrections are documented in the source review.

C17 was a pure bug-fix release with no new language features, but C23 (published as ISO/IEC 9899:2024) is the most substantial revision since C11 — and is the reason the total keyword count climbs past 50. Its most notable additions include:

  • nullptr and nullptr_t: nullptr is a predefined null-pointer constant and keyword. nullptr_t is its type name supplied by <stddef.h>, not another keyword. This type is distinct from pointer and arithmetic types and converts to pointer types as a null pointer value. NULL remains available.
  • constexpr: Defines a constant object subject to constant-expression initialization rules. In C23 this is an object facility, not C++-style constexpr functions. An ordinary const int is not automatically an integer constant expression.
  • typeof and typeof_unqual: Derive a type from an expression or type name. typeof_unqual removes top-level qualifiers and atomic qualification. An ordinary operand is not evaluated, but variably modified types introduce evaluation cases, so “always unevaluated” is too broad.
  • Familiar names become keywords. bool, true, false, static_assert, alignas, alignof, and thread_local no longer need their former header macros in C23. The older underscore spellings are obsolescent alternatives, not a promise that the old macros remain defined. Before C23 the relevant macros came from <stdbool.h>, <assert.h>, <stdalign.h>, or <threads.h>, depending on the name.
  • _BitInt(N) — bit-precise integer types whose specified width determines their value range, including a sign bit for signed types, subject to the implementation’s supported maximum. That width does not promise an object storage size of exactly that many bits.
  • Standard attributes — bracketed annotations such as [[deprecated]], [[maybe_unused]], [[nodiscard]], and [[fallthrough]], with effects specified by each attribute. Some guide diagnostics; others assert semantic contracts. Standard attributes can be ignored without changing a correct program’s semantics, but a false asserted property can lead to undefined behavior.
  • Smaller conveniences — binary literals (0b101010), digit separators for readability (1'000'000), and #embed for pulling the contents of a binary file directly into source code.
  • Other type facilities: auto can infer an object's type from its initializer in supported declaration forms. _Decimal32, _Decimal64, and _Decimal128 are decimal floating types on implementations supporting that conditional feature.

Feature support depends on the exact compiler, version, target, standard-library implementation, and selected language mode. Check those before using C23 facilities; do not assume a C17 toolchain accepts C23 syntax or that every optional feature exists.

Ready for the next idea?

Mark this chapter as read whenever you feel ready.

CHAPTER 71 / 73

In this chapter

Modern C: C23 features and adoption

Search all 73 chapters in both languages.EN + HG

Try “pointer”, “why int”, or “undefined behavior”.

Concepts connect. Follow your curiosity.↑ ↓ to explore · Enter to open
MAKE YOURSELF COMFORTABLE

Your reading space

Appearance

A clear canvas with balanced contrast.

Text size

100%
AA

Reading tools

Your data stays in this browser

Export a backup before changing browsers or replacing an older version of the reader.

YOUR PERSONAL MARGINS

My notebook

Saved on this device
A LITTLE CLARITY

The glossary

A starting meaning, then a chapter to go deeper.

A QUICK DEFINITION

A little clarity

Read the full explanation →

A thought worth keeping