Re: bool variable.(a non-standard question)
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Sat, 02 Sep 2006 09:18:58 -0400
shaanxxx wrote:
I have code which says
#define MYBOOL int
This code is very old. people who have written is not avaible. I
was thinking what could be reason.
1) bool datatype was not available that time (10 years back:
correct me if i am wrong)
2) int was word aligned (16bit and 32bit). Writter of above code
doesnt want to give choice to compiler.
if we say bool , compiler can represent this on his way (again,
correct me if i am wrong)
C still has no bool type, unless you #include <stdbool.h> in C99
systems. After which true and false will be macros that expand to
integers 1 and 0 respectively, and bool will expand to _Bool (which
is system defined, usually as an int).
However, since the dawn of time, C has defined logical expressions
(e.g. (x < y)) as returning either 0 or 1. This is why !!x can be
used to force the value to those, and why we can do arithmetical
tricks with booleans.
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
.
- References:
- bool variable.(a non-standard question)
- From: shaanxxx
- bool variable.(a non-standard question)
- Prev by Date: Re: bool variable.(a non-standard question)
- Next by Date: Re: C IDE Recommendations
- Previous by thread: Re: bool variable.(a non-standard question)
- Next by thread: Re: bool variable.(a non-standard question)
- Index(es):
Relevant Pages
|