Cryptic C

David Herron, NPR Lover david at ukma.UUCP
Thu Aug 22 14:20:06 AEST 1985


In article <675 at gitpyr.UUCP> robert at gitpyr.UUCP (Robert Viduya) writes:
>In article <1056 at mtgzz.UUCP>, dsk at mtgzz.UUCP (d.s.klett) writes:
...
>> 	typedef enum { False , True } Boolean;
...
>
>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;

Well, I personally prefer:

	#define TRUE (1==1)
	#define FALSE (1==0)
	typedef char bool;

Which is succint, to the point, and *machine*independant*!

'sides, constant expressions are calculated at compile time anyway.
-- 
--- David Herron
--- ARPA-> ukma!david at ANL-MCS.ARPA
--- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david
---        {ihnp4,decvax,ucbvax}!cbosgd!ukma!david

Hackin's in me blood.  My mother was known as Miss Hacker before she married!



More information about the Comp.lang.c mailing list