Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site allegra.UUCP Path: utzoo!linus!philabs!seismo!harpo!eagle!allegra!alan From: alan@allegra.UUCP (Alan S. Driscoll) Newsgroups: net.unix Subject: Re: typedefs, etc. Message-ID: <2209@allegra.UUCP> Date: Fri, 13-Jan-84 23:59:29 EST Article-I.D.: allegra.2209 Posted: Fri Jan 13 23:59:29 1984 Date-Received: Sun, 15-Jan-84 00:10:35 EST References: <1200@ucbcad.UUCP> <430@bbncca.ARPA>, <4626@umcp-cs.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 50 From: chris@umcp-cs.UUCP Newsgroups: net.unix Subject: Re: typedefs, etc. - (nf) Re: From: keesan@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! You're wrong. In fact, typedef enum { FALSE, TRUE } bool; is guaranteed to do the right thing. The C Reference Manual (September, 1980) states The identifiers in an enum-list are declared as constants, and may appear wherever constants are required. If no enumerators with = appear, then the values of the corresponding constants begin at 0 and increase by 1 as the declaration is read from left to right. An enumerator with = gives the associated indentifier the value indicated; subsequent identifiers continue the progression from the assigned value. So, FALSE will be given the value 0 and TRUE the value 1 because of their *positions* in the declaration. It amazes me how much misinformation appears on the net. Alan S. Driscoll AT&T Bell Laboratories