TRUE and FALSE

david nugent david at csource.oz.au
Tue Aug 28 05:44:54 AEST 1990


In <514 at demott.COM> kdq at demott.COM (Kevin D. Quitt) writes:

> >Unfortunately, using TRUE and FALSE opens a great gaping hole:
> >one would expect that
> >
> >	x == TRUE
> >
> >would mean the same as
> >
> >	x != FALSE
> >
> >but of course it doesn't -- at least not if you use the usual C
> >convention that 0 is false and any other value is true.

> We use 

> #define	TRUE	(1==1)
> #define	FALSE	(1!=1)

>     defined that way for hysterical raisins (broken compiler).  We are
> aware of the problem above, and never test booleans that way.  TRUE and
> FALSE are used for assignment purposes only.  It makes the intent of the
> code more obvious. 


Shouldn't

 # define FALSE 0
 # define TRUE  (!FALSE)
 
_always_ work?

I have been using this for a considerable amount of time, and so far
haven't seen any problems with it.  Or are there some circumstances
where this might not cover all cases?

Regards,

david


-- 

        Fidonet: 3:632/348   SIGnet: 28:4100/1  Imex: 90:833/387
              Data:  +61-3-885-7864   Voice: +61-3-826-6711
 Internet/ACSnet: david at csource.oz.au    Uucp: ..!uunet!munnari!csource!david



More information about the Comp.lang.c mailing list