Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!ucla-cs!alex From: alex@ucla-cs.ARPA (Alex Quilici) Newsgroups: net.lang.c Subject: re: boolean datatypes Message-ID: <15942@ucla-cs.ARPA> Date: Tue, 17-Jun-86 13:03:53 EDT Article-I.D.: ucla-cs.15942 Posted: Tue Jun 17 13:03:53 1986 Date-Received: Thu, 19-Jun-86 19:40:19 EDT References: <210@pyuxv.UUCP> <660@ucbcad.BERKELEY.EDU> Reply-To: alex@ucla-cs.UUCP (Alex Quilici) Organization: UCLA Computer Science Dept. Lines: 31 >The problems come when you write: > > bool b; > int a, c; > > b = (a == c); > >My compiler gives an "enumeration type clash". It would seem that you >can't legally convert integers to enum members... yes, you can. c just won't do the conversion for you automatically. try using a cast: b = (bool) (a == c); i frequently use enums to define constants that indicate various errors. i find that whenever i have to worry about many errors typedef enum {NOPASS, BADRD, ... } ERROR; is more convenient than #define NOPASS 1 #define BADRD 2 ... i also find that my programs are more readable because the compiler forces me to declare all variables or functions that hold or return an error status to be of type ERROR, rather than simply int. alex