Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site opus.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!genrad!panda!talcott!harvard!seismo!hao!nbires!opus!rcd From: rcd@opus.UUCP (Dick Dunn) Newsgroups: net.lang.c Subject: Re: Cryptic C (enum as boolean type) Message-ID: <19@opus.UUCP> Date: Fri, 30-Aug-85 01:02:04 EDT Article-I.D.: opus.19 Posted: Fri Aug 30 01:02:04 1985 Date-Received: Sun, 1-Sep-85 12:41:13 EDT References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <1056@mtgzz.UUCP> Organization: NBI,Inc, Boulder CO Lines: 16 > Instead of using #defines for the boolean values, I > would rather see enumerated data types used. In general, > C programmers seem to prefer #defines to defining a data > type that can be checked during compilation. > > typedef enum { False , True } Boolean; Whether this works depends on your compiler's view of enums. If it treats enums as a slight variant on integers (which to my tastes is pretty sloppy), you're OK. However, if it uses the very restricted view which doesn't allow arithmetic on enums, the above definition will prevent the "usual" logical operators !, &, ^, and | from working with objects of type Boolean. -- Dick Dunn {hao,ucbvax,allegra}!nbires!rcd (303)444-5710 x3086 ...Relax...don't worry...have a homebrew.