Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!gatech!bloom-beacon!husc6!cmcl2!brl-adm!brl-smoke!gwyn
From: gwyn@brl-smoke.ARPA (Doug Gwyn )
Newsgroups: comp.lang.c
Subject: Re: Defining TRUE and FALSE
Message-ID: <6123@brl-smoke.ARPA>
Date: Thu, 16-Jul-87 14:06:10 EDT
Article-I.D.: brl-smok.6123
Posted: Thu Jul 16 14:06:10 1987
Date-Received: Sat, 18-Jul-87 08:09:28 EDT
References: <13851@watmath.UUCP> <632@itsgw.RPI.EDU> <13259@topaz.rutgers.edu>
Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) )
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 24
Keywords: boolean, true, false

In article <13259@topaz.rutgers.edu> ron@topaz.rutgers.edu (Ron Natalie) writes:
>The problem is that C defines FALSE to be zero and TRUE to be non
>zero.  Hence, while you may define FALSE to be 0, there is nothing
>you can define true to be that will consistantly work as things that
>set true values are free to use any non-zero number.

This isn't quite precise.  There are two contexts: (a) setting a "true"
value; (b) testing the "truth" of a value.  When C specifies the former,
for example the value of a relational expression, it specifies that the
value will be either 0 or 1 (NOT "any non-zero value" for true); when C
specifies the latter, then indeed any non-zero value tests as "true".

>The correct test for truth is the value by itself ...

Right -- i.e., "if (expr)", NOT "if (expr == TRUE)".

>On a different light, I've noticed nobody has mentioned the construct
>of seting a variable of TRUE by incrementing it.

Yucky!  The principle "say what you mean" implies that "flag = TRUE;"
is much better than "flag++".  Note also that if one changes the initial
value of the flag (to have the option enabled by default, for example,
while leaving in support for the previous enabling option), the ++
approach gives it a funny value instead of the simple truth value 1.