C23, formally published in 2024, is the largest update to C in over a decade, closing several long-standing gaps compared to C++.
#include <stdio.h>
int main(void) {
bool isReady = true; // C23: bool/true/false are now built-in keywords
// (previously needed #include <stdbool.h>)
int *p = nullptr; // C23: dedicated, type-safe null-pointer keyword
// (previously only NULL, a macro, less type-safe)
constexpr int max = 100; // C23: compile-time constant, properly typed
auto count = 42; // C23: type inference — count becomes 'int' automatically
long total = 1'000'000; // C23: digit separators improve readability of large numbers
typeof(count) another = 10; // C23: typeof — declare a variable matching another's type
printf("%d %d %d\n", isReady, max, count);
return 0;
}
bool, true, false, and nullptr are now genuine language keywords in C23 — no header inclusion required, and nullptr has its own distinct type, catching mistakes (like passing it where an integer 0 was intended) that the old NULL macro couldn't. constexpr provides a properly-typed, guaranteed-compile-time constant, generally superior to both #define and plain const for simple values (see the "Constants and Type Qualifiers" lesson for the comparison).
auto lets the compiler infer a variable's type from its initializer, reducing repetition for obvious cases (though many teams still prefer writing the type explicitly for clarity, similar to the debate in C++). typeof/typeof_unqual let you declare a new variable with the same type as an existing expression, useful in generic macros. Digit separators (1'000'000) are purely a readability aid for the human reading the source — they have zero effect on the compiled value.
Other notable C23 additions include the #embed directive (for including a file's raw contents directly at compile time, e.g. embedding an image or a shader into a binary without external tooling) and attributes like [[deprecated]], [[nodiscard]], and [[maybe_unused]] for expressing intent to both the compiler and other readers of the code. Support is still maturing — GCC 13/14 and Clang 17+ implement most, but not all, of C23, so always check current compiler documentation before depending on a specific feature in production code.