Definition of boolean type

Norman Diamond diamond at csl.sony.JUNET
Tue Feb 14 13:47:00 AEST 1989


In article <15906 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:

> Perhaps the biggest problem with boolean types, and definitions for
> `TRUE' and `FALSE' (or True and False or true and false or . . .)

> 	#define FALSE 0
> 	#define TRUE ~FALSE
> 	...
> 	/* these macros return TRUE when the queue is empty/full/... */
> 	#define ISEMPTY(eq) ((eq)->head.foo == (eq)->tail.foo)
> 	...
> 	if (ESEMPTY(eq) == TRUE) bar();

> It is left as an exercise to the reader to determine why this test
> will never call function bar().

A boolean operator would make it work correctly:

	#define TRUE !FALSE

Of course, TRUE and FALSE *should* be used only as the right-hand-sides
of assignments, not as operands for a comparison.  However, it is not
correct to say that the biggest problem with <x> is that some programmer
codes a bug in which he forgets to use <x>'s operators.



More information about the Comp.lang.c mailing list