pointer size vs integer size

J. Shapiro jss at sjuvax.UUCP
Sun Feb 3 10:23:03 AEST 1985


[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



More information about the Comp.lang.c mailing list