Definition of boolean type

mcdonald at uxe.cso.uiuc.edu mcdonald at uxe.cso.uiuc.edu
Sun Feb 12 01:36:00 AEST 1989



>	#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().
And on some computers
      (FALSE == TRUE)   returns 0, while on others
      (FALSE == TRUE)   will return 1! (Hint: There are a few, a very
few, C compilers for one's complement machines, and on some of those
0 == -0). I admit this is farfetched.



More information about the Comp.lang.c mailing list