typedefs, etc. - (nf)

chris at umcp-cs.UUCP chris at umcp-cs.UUCP
Thu Jan 5 17:04:01 AEST 1984


Re:
	From: keesan at bbncca.UUCP

	[ Re: ...  typedef enum { FALSE, TRUE } bool; ... ]

	I question the utility of a 'bool' type which generates
	type-clashes with boolean expressions.  However, if you
	insist on using it, do you object to 

		return( (bool)(getchar() == 'y') );

	?  This avoids the type-clash warning, and is guaranteed
	to work.

Unfortunately it's not *guaranteed* to work, unless you use

	typedef enum { FALSE = 0, TRUE = 1 } bool;

to ensure that (bool) 0 == FALSE and (bool) 1 == TRUE.  Otherwise
the result of a boolean expression may be neither FALSE nor TRUE!

Personally I just use integers as boolean-variables.  (As if anyone
cares.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris.umcp-cs at CSNet-Relay



More information about the Comp.unix mailing list