[net.lang.c] pointer size vs integer size

jss@sjuvax.UUCP (J. Shapiro) (02/03/85)

[Aren't you hungry...?]

	Someone recently pointed out that sizeof(int) <> sizeof(int *)
necessarily.  While I don't want to go into the validity of that argument
vis a vis K&R, the fact of the matter is that many compilers (e.g. Manx C
for 68K) do not adopt sizeof(int) == sizeof(int *) because it simply isn't
true in the processor architecture.

	What would peoples response be to the idea of having a #DEFINE
somewhere which ran something like

#DEFINE	ptrint	int
#DEFINE	ptrint	long
#DEFINE ptrint	foo

as appropriate, and then using declarations such as

ptrint foo;

typedef could also be used.  This does not break anything in C, and would
allow people concerned with portability to write the code portably.

On the other hand, the only place I can think of where one really *needs* a
pointer to be an integer is in doing explicit pointer initialization, which
isn't portable anyway. Though the #IFDEF facility could handle even this if
intelligently used.

Jonathan S. Shapiro

Doug Gwyn (VLD/VMB) <gwyn@Brl-Vld.ARPA> (02/10/85)

Using (int *) for "pointer to int" is even MORE portable.
Geez.