Is there a bool type in C language ?, C language bool type
I have never noticed that when I recently wrote a DSP Algorithm in C language, I accidentally found that the bool type variables defined in my function are in VC6.0 (I mainly use it to check for syntax errors) in the compilation, an error is reported, indicating that the bool type is not defined. After using C and C ++ for so long, I have always thought that the basic type of bool should be the built-in type of C language. How can it be not defined? It turns out that my thoughts are totally wrong.
With the Internet, all problems have become so easy that I can easily find relevant answers.
There is no bool (Boolean) type in C language, and it is only available in C ++. That is to say, it is no problem to use the bool type in C ++. The bool type has only two values: true = 1 and false = 0.
However, bool type variables are defined in the C99 standard. In this case, as long as the header file <stdbool. h> is introduced, the bool type can be used normally in the C language. I have verified this in Fedora9. Its built-in compiler is gcc 4.3.0, which complies with the C99 standard. However, in VC6.0, the error "stdbool. h" is not found. It seems that VC6.0 is old.
Therefore, to be compatible with various compilers, we recommend that you define them by yourself. Pai_^
# Define bool char
# Define ture 1
# Define false 0
Http://www.cnblogs.com/roucheng/p/css3menu.html
Http://roucheng.cnblogs.com/