Time to standardize "true" and "false"
King Su
wen-king at cit-vax.Caltech.Edu
Wed Sep 27 22:54:15 AEST 1989
In article <393 at cpsolv.UUCP> rhg at cpsolv.uucp (Richard H. Gumpertz) writes:
>The biggest advantage of a built-in boolean type would be that casts TO it
<would test for zero/non-zero rather than just trucating the high-order bits
>if sizeof(source) is bigger than sizeof(bool). Also, (bool)X & (bool)Y would
<do "right" thing even if X was 4 and Y was 32. In other words, & would be
>equivalent to && for type bool except that both operands would be evaluated.
Why not just do:
#define bool(a) (!!(a))
Then just use bool(X) whenever you wanted to use (bool)X.
--
/*------------------------------------------------------------------------*\
| Wen-King Su wen-king at vlsi.caltech.edu Caltech Corp of Cosmic Engineers |
\*------------------------------------------------------------------------*/
More information about the Comp.lang.c
mailing list