Cryptic C

Robert Viduya robert at gitpyr.UUCP
Thu Aug 22 01:24:57 AEST 1985


In article <1056 at mtgzz.UUCP>, dsk at mtgzz.UUCP (d.s.klett) writes:
> 
> 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;
> 
> Don Klett

The problem with enums is that compiler allocate them as ints.  This
means 1 wasted byte on a machine with a 16-bit int, 3 wasted bytes on
a machine with a 32-bit int and so on and so forth.  All you really
need is 1 byte (on most conventional machines).  I personally prefer:

    #define	TRUE	1
    #define	FALSE	0
    typedef	char	bool;


				robert
-- 
Robert Viduya							01111000
Georgia Institute of Technology

UUCP:   {akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!robert
        {rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!robert
BITNET:	CCOPRRV @ GITVM1



More information about the Comp.lang.c mailing list