Is there a bool type in C language ?, C language bool type

Source: Internet
Author: User

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/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.