Definition of boolean type

Chris Torek chris at mimsy.UUCP
Sat Feb 11 12:39:31 AEST 1989


In article <3645 at arcturus> evil at arcturus.UUCP (Wade Guthrie) writes:
>Why make a simple idea more complicated?

Indeed.

Perhaps the biggest problem with boolean types, and definitions for
`TRUE' and `FALSE' (or True and False or true and false or . . .)
is exemplified by the QDSS driver supplied with 4.3BSD-tahoe (for
which no one at Berkeley is at fault).  It had the following definitions
(somewhat paraphrased):

	#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)

The code then read

		if (ESEMPTY(eq) == TRUE) bar();

It is left as an exercise to the reader to determine why this test
will never call function bar().
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list