Path: utzoo!mnetor!uunet!lll-winken!lll-tis!oodis01!uplherc!sp7040!obie!wes From: wes@obie.UUCP (Barnacle Wes) Newsgroups: comp.lang.c Subject: Re: C Style (Was Re: == vs =) Message-ID: <175@obie.UUCP> Date: 24 Apr 88 20:55:23 GMT References: <11216@brl-adm.ARPA> <2111@chinet.UUCP> <4403@garfield.UUCP> <255@oink.UUCP> Organization: the Well of Souls Lines: 22 Summary: booleans in C In article <255@oink.UUCP>, jep@oink.UUCP (James E. Prior) writes: > if (var==TRUE) > > is not only abominable, it can be dangerous. var==TRUE tends to presume > that the only valid values of var are FALSE and TRUE. Right. The only really safe way to do this is: typedef enum boolean {false, true}; ... boolean foo; ... if (foo == true) { ... But, of course, then you can test your `booleans' directly too, like if (foo) { ... -- /\ - "Against Stupidity, - {backbones}! /\/\ . /\ - The Gods Themselves - utah-cs!uplherc! / \/ \/\/ \ - Contend in Vain." - sp7040!obie! / U i n T e c h \ - Schiller - wes