Skip to content
Tutorials Center
My learning

Topics

C Reference ยท Concepts and Tools

What is new in C23

A tour of the C23 standard: nullptr, constexpr, typeof, bool keywords, attributes, auto, _BitInt, checked arithmetic, binary literals and what the online runner supports.

C23 (ISO/IEC 9899:2024) is the largest update since C99. It does not change the character of the language; it removes sharp edges and adds features that C programmers had been writing as macros or compiler extensions for years: a real null pointer constant, compile-time constants, type inference, standard attributes, and safer integer arithmetic.

GCC 15 compiles in C23 mode by default for -std=gnu23, and the online runner uses -std=c23. Most language features work there. The library additions depend on the C library, which on the runner (glibc 2.28) lacks some of them; those are marked read-only below.

Try it

C Language features that work on the runner

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

C Checked arithmetic and bit-precise integers

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Language changes

Feature What it gives you Page
nullptr, nullptr_t A null pointer constant with its own type, so it cannot be mistaken for the integer 0 in _Generic or variadic calls. nullptr
constexpr Named constants usable in constant expressions (array sizes, static_assert) without macros or enum tricks. constexpr
bool, true, false Real keywords; <stdbool.h> becomes unnecessary. bool
typeof, typeof_unqual The type of an expression or type name, standardized from a GCC extension. typeof
auto Type inference from the initializer (auto n = 10;). Not allowed for function parameters. register and auto
[[attributes]] [[nodiscard]], [[maybe_unused]], [[deprecated]], [[fallthrough]], [[noreturn]], [[unsequenced]], [[reproducible]]. Attributes
_BitInt(N) Integers of a chosen exact width (no implicit promotion to int). _BitInt
#embed Include the bytes of a file as an initializer list. #embed
#elifdef, #elifndef, __has_include, __has_c_attribute Shorter conditional compilation and feature testing. Conditional compilation
#warning Standardized (it was a common extension). #error and #warning
__VA_OPT__ Handles an empty variable-argument list in macros. Variadic macros
Binary literals 0b101, digit separators 1'000 Readable constants. Literals
static_assert without message static_assert(cond); static_assert
Empty initializer {} Zero-initializes any object, including structs and arrays. Designated initializers
Enum with fixed underlying type enum E : uint8_t { ... }. enum
unreachable() In <stddef.h>; marks code that can never execute. Undefined behavior
Two's complement Signed integers are required to use it (overflow is still undefined). Integer overflow
Labels before declarations, char8_t, u8 string literals as char8_t Smaller language cleanups.
Removed K&R-style function definitions, trigraphs, implicit function declarations, () meaning "unspecified arguments" (now it means (void)). Function declarations

Library changes

  • <stdckdint.h>: ckd_add, ckd_sub, ckd_mul for overflow-checked arithmetic; see stdckdint.h. Works on the runner.
  • <stdbit.h>: stdc_count_ones, stdc_leading_zeros, stdc_bit_width and related functions; see stdbit.h. Not available in the runner's glibc 2.28, so those examples are read-only.
  • memset_explicit (cannot be optimized away, for wiping secrets), memccpy, strdup and strndup now standard, free_sized, free_aligned_sized in <stdlib.h>.
  • strtol and friends accept the 0b prefix in base 0 or 2. The runner's glibc 2.28 ignores it, so do not depend on it there.
  • printf("%b") and %B print binary; also missing in glibc 2.28, so not usable in the runner.
  • Math: decimal floating types (_Decimal32/64/128, optional), more <math.h> functions (exp2m1, rsqrt, compoundn, ...), <float.h> additions.
  • timegm, gmtime_r and localtime_r are standard in <time.h>.

Usage notes

  • Support differs. GCC 13+, Clang 18+ cover most language features; library headers depend on glibc 2.39+ or another current C library. Older compilers use the draft name -std=c2x.
  • Detect, don't assume: #if __STDC_VERSION__ >= 202311L for the language, __has_include(<stdbit.h>) for headers.
  • bool as a keyword means code that did typedef int bool; or #define bool int now fails to compile in C23 mode.
  • nullptr is not the integer 0: pass nullptr where you mean a pointer, especially to variadic functions.
  • auto changed meaning: it used to be a storage class specifier that nobody wrote.
  • Back to older code. To keep a header usable from C11, wrap C23 features in #if checks or macros; see Portability.