Cryptic C
Arthur David Olson
ado at elsie.UUCP
Sun Aug 25 02:21:43 AEST 1985
> > > . . .I personally prefer:
> > >
> > > #define TRUE 1
> > > #define FALSE 0
> > > . . .
> > . . .I personally prefer:
> >
> > #define TRUE (1==1)
> > #define FALSE (1==0)
> > . . .
> Oh? On what machine is (1==1) equal to 0, or (1==0) not equal to 0? . . .
Yes, the good book (K&R) says that (1==1) is always 1.
The advantage of the second approach above is that it obviates the need to
remember this fact. The disadvantage of the second approach above is that it
gives "lint" fits ("constant in conditional context").
As for what *I* prefer:
#ifndef TRUE
#define TRUE (1)
#define FALSE (0)
#endif
where the parenthesized definitions match those in "curses.h" to ensure that
if a reference to "curses.h" appears after the above lines I won't get a
"macro redefined to a different value" diagnostic from the C preprocessor.
--ado
More information about the Comp.lang.c
mailing list