Course contentsShow
← C
Lesson 969 of 1,21913. Advanced CFree lesson

C23: The `bool`, `true`, and `false` keywords

C23: The bool, true, and false keywords

What you'll learn: How the C23 standard finally makes Boolean types a native part of the language without requiring extra headers.

The Long Road to "True"

For decades, C had a bit of an identity crisis regarding truth. In the early days, we simply used integers: 0 was false, and anything else was true. If you wanted to make your code readable, you had to manually define constants or include <stdbool.h> (introduced in C99), which gave you bool as a macro for the slightly clunky _Bool type.

Think of it like using a generic adjustable wrench for every nut and bolt. It works, but it’s not the specific tool designed for the job. With the C23 standard, C finally gives us the dedicated "socket wrench" we’ve always wanted. bool, true, and false are now official, reserved keywords in the language.

No More Headers

In older versions of C, if you typed bool is_running = true; without including a header file, the compiler would throw a tantrum, claiming it had no idea what a "bool" was.

In C23, these are built-in. This brings C in line with C++ and makes the code much cleaner. You no longer need to remember #include <stdbool.h> at the top of every file just to perform simple logic.

How it looks in C23

Because these are now native keywords, the compiler treats them with first-class importance. Here is how you use them in a modern C23 environment:

#include <stdio.h>

int main(void) {
    // No <stdbool.h> needed in C23!
    bool is_c23_ready = true;
    bool is_old_syntax = false;

    if (is_c23_ready) {
        printf("The boolean keywords are now native!\n");
    }

    // Behind the scenes, bool still occupies 
    // enough space to store a 0 or 1.
    printf("Size of bool: %zu byte\n", sizeof(bool));

    return 0;
}

Why this matters

This change is about consistency and modernization. By making bool a keyword, C reduces the "boilerplate" code you have to write. It also prevents developers from accidentally naming their own variables true or false in ways that might conflict with standard logic. It’s a small step that makes the language feel more cohesive and easier for beginners to pick up.

Key takeaway

C23 promotes bool, true, and false to native keywords, eliminating the need to include <stdbool.h> for basic logical types.