Cryptic C

Richard L. Klappal rlk at chinet.UUCP
Sun Aug 25 18:38:34 AEST 1985


In article <685 at gitpyr.UUCP> robert at gitpyr.UUCP (Robert Viduya) writes:
>In article <2076 at ukma.UUCP>, david at ukma.UUCP (David Herron, NPR Lover) writes:
>> In article <675 at gitpyr.UUCP> robert at gitpyr.UUCP (Robert Viduya) writes:
>> >
>> > ... 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*!
>> 
>
>Oh?  On what machine is (1==1) equal to 0, or (1==0) not equal to 0?  In
>section 7.6 (Relational operators, Appendix A - C Reference Manual from
>K&R's The C Programming Language), it explicitly states that the logical
>operators all yield 0 if the relation is false and 1 if the relation is
>true.  Nothing is mentioned about possible variations due to implementation
>machine differences.
>
>				robert
>-- 
>Robert Viduya							01111000
Maybe not 'machine independent' in C, but the logic will
be 'language independent' (using the appropriate equality operator).

I've had to debug an awful lot of assembly language where
a cpu 'Z' flag (zero-flag) was used as TRUE.  About like strcmp
returns 0 if two strings are the same so that you cannot extend
the concept 

	if (string1==string2) {...}

that works in F77, PL/I, BASIC, etc.



Richard Klappal

UUCP:		..!ihnp4!chinet!uklpl!rlk  | "Money is truthful.  If a man
MCIMail:	rklappal		   | speaks of his honor, make him
Compuserve:	74106,1021		   | pay cash."
USPS:		1 S 299 Danby Street	   | 
		Villa Park IL 60181	   |	Lazarus Long 
TEL:		(312) 620-4988		   |	    (aka R. Heinlein)
-------------------------------------------------------------------------



More information about the Comp.lang.c mailing list