BOOLEAN as enum
Alan Filipski
al at gtx.com
Thu Mar 29 07:35:45 AEST 1990
It has been proposed around here to define a Boolean type as
typedef enum {FALSE, TRUE} BOOLEAN;
to me there seems to be very little difference between this and the more
usual
#define FALSE 0
#define TRUE 1
(and, optionally, either typedef int BOOLEAN or typedef char BOOLEAN)
The only difference I see is that lint could complain about some
clashes, as in
BOOLEAN p()
{
return 99;
}
or
BOOLEAN x;
x = 10;
which complaints might be useful. however, lint would then also
complain about things like:
x = (a==b);
or
BOOLEAN p()
{
return (a==b);
}
which one probably does not want to see complaints about
(but which could be circumvented with a logically gratuitous cast).
anyway, my question is this: aside from possible lint messages,
does the ANSI model for enums imply any difference between the
enum or #define approach to TRUE/FALSE? My personal opinion is that,
since neither approach provides a real BOOLEAN type, one
should stick with customary usage. Comments?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
( Alan Filipski, GTX Corp, 8836 N. 23rd Avenue, Phoenix, Arizona 85021, USA )
( {decvax,hplabs,uunet!amdahl,nsc}!sun!sunburn!gtx!al (602)870-1696 )
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the Comp.lang.c
mailing list