Is there a bool type in C language?

Source: Internet
Author: User

Have not noticed before, recently in C language write DSP algorithm, accidentally found my function in the definition of BOOL type variable in VC6.0 (I mainly use it to check the syntax error) in the compilation actually error, said the bool type is not defined. It took so long C and C + +, has always felt that the basic type of bool, C language should be built-in type, how can not be defined? It turns out that my idea was completely wrong.

With the network, all the problems have become so easy, I easily searched the relevant answers.

There is no bool (Boolean) type in C, C + +, which means that there is no problem in C + + using the bool type. The bool type has only two values: true = 1, false=0.

However, the C99 standard also defines the BOOL type variable. At this point, as long as the introduction of the header file <stdbool.h>, you can use the bool type in the C language normally. I have verified this in Fedora9, and its own compiler is GCC 4.3.0, which complies with the C99 standard. But in the VC6.0, will be reported to find not the head file Stdbool.h error, it seems VC6.0 really older.

So, to be compatible with a variety of compilers, or define it yourself. ^_^

#define BOOL Char
#define TURE 1
#define FALSE 0

Http://www.cnblogs.com/roucheng/p/css3menu.html

http://roucheng.cnblogs.com/

Is there a bool type in C language?

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.