"sizeof(int) < sizeof(char *): a defense"

H.MORRIS hom at hocda.UUCP
Fri Mar 23 06:53:39 AEST 1984


That reminds me of why I finally got un-pissed-off at people who
write 68000 compilers that way; namely the part of the spec that
says every "integerish" data type like char, etc. gets widened
to int when passed in a function or when arithmetic gets performed
on it.  Until then my attitude was "if you want it to run fast,
declare a `short'".  So I can see the point of having 16 bit ints
and 32 bit pointers.  I did some coercing back and forth between
integer and pointer types and to make it portable among a class
of "reasonable" machines, used the following type:
#ifdef mc68	/* or mc68000? */
typedef unsigned long	PTRasINT;
#else
typedef unsigned PTRasINT;
#endif
Thus for instance in subtracting pointers that might differ by more
than 16 bits worth, you can say
	diff = (PTRasINT)s - (PTRasINT)t;
Hal Morris ...hocad!hom



More information about the Comp.lang.c mailing list