Re: PROPOSED: 32/64 bit coexistence
"VomLehn, David" <David.VomLehn@compaq.com> wrote:
> The last time I looked, the C standard said that an implementation must
> have an *integer type* big enough to hold all bits of a pointer. This
> integer type did not have to be an int--it could be a long.
There isn't even any such requirement. But you're right that programs
shouldn't use int directly: if there is such a type, the
implementation should typedef it as intptr_t in C99. Also, since C89,
IIRC, size_t (unsigned) is the integer type of sizeof expressions, and
ptrdiff_t (signed) is the integer type of pointer differences. These
two types are the ones that should be used for pointer arithmetic.
The standard doesn't guarantee they are large enough to represent all
object sizes or pointer differences, but if such types exist, these
will be them.