Re: rationale for #define true 1 in stdbool.h
- From: "Old Wolf" <oldwolf@xxxxxxxxxxxxxx>
- Date: 10 Jan 2006 16:34:25 -0800
Eric Sosman wrote:
> Personally, I still don't understand the motivation for
> adding _Bool to the language.
For me, it's desirable because assigning any non-zero value
to it causes it to have a non-zero value. This is not true for
any builtin type except for unsigned long long, which would
be a waste of memory if it were used as a boolean type.
I have accidentally written code like this:
bool b = (flags & FLAG_FOO);
where FLAG_FOO is something like 0x100. It took a
long debugging session to track down the problem; even
when I'd isolated the problem to this one block of code,
I still couldn't for the life of me figure out what was going on,
until I looked up the definition of 'bool'. (It turned out to
be a typedef for unsigned char).
.
- Follow-Ups:
- Re: rationale for #define true 1 in stdbool.h
- From: lawrence . jones
- Re: rationale for #define true 1 in stdbool.h
- From: Eric Sosman
- Re: rationale for #define true 1 in stdbool.h
- References:
- rationale for #define true 1 in stdbool.h
- From: Ben Hinkle
- Re: rationale for #define true 1 in stdbool.h
- From: Eric Sosman
- rationale for #define true 1 in stdbool.h
- Prev by Date: Re: float pointers
- Next by Date: Re: x86 Stack Confusion
- Previous by thread: Re: rationale for #define true 1 in stdbool.h
- Next by thread: Re: rationale for #define true 1 in stdbool.h
- Index(es):
Relevant Pages
|