C Style (Was Re: == vs =)

Barnacle Wes wes at obie.UUCP
Mon Apr 25 06:55:23 AEST 1988


In article <255 at oink.UUCP>, jep at 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



More information about the Comp.lang.c mailing list