Fix [Error] unknown type name ‘bool’ in C

If you are new to C programming, it is very common that you face an unknown type name ‘bool’ error. Here, the compiler is trying to tell you that it is not able to recognize the type ‘bool’ which you have added to your C program.

The unknown type name ‘bool’ error occurs when you add a boolean data type variable to your program using the bool keyword, for eg. bool myVar;, but the compiler doesn’t recognize the bool keyword. So, it complains about it and results in a compile-time error.

[Error] unknown type name 'bool' in C

The reason for this error is that the bool data type is not a part of the standard C language like other data types such as int, char, float, double, etc. Therefore, the compiler fails to recognize it.

Solution to Fix the unknown type name ‘bool’ Error

To fix the unknown type name ‘bool’ error, you have to include the <stdbool.h> header library at the top of your C program.

When you add the <stdbool.h> library at the top of your program, the compiler becomes able to recognize the bool data type and compiles the code without any errors.

Here is a sample code example:

#include <stdio.h>
#include <stdbool.h>  // <--- Include this library

int main(){
    bool myVar;
    // Write your code here
    return 0;

I hope this post helped you.

Thanks for reading.


  • Manoj Kumar

    Hi, My name is Manoj Kumar. I am a full-stack developer with a passion for creating robust and efficient web applications. I have hands-on experience with a diverse set of technologies, including but not limited to HTML, CSS, JavaScript, TypeScript, Angular, Node.js, Express, React, and MongoDB.

    View all posts