[M3devel] long vs. INTEGER? ranges vs. word/integer?

Roland Illig roland.illig at gmx.de
Sat Jan 3 10:05:58 CET 2009


Peter Eiserloh schrieb:
> Jay,
> 
> In "C" a
> long is specified by the language spec to be an integral 
> type big enough to hold a pointer.  Longs in "C" may be
> bigger than a pointer, but they must be at least that size.

That's wrong. There is nothing in the C99 standard that guarantees that.
The only guarantee is that long is at least as large as int. If your
assumption was true, there wouldn't have been the need to add intptr_t
and uintptr_t to the language.

Even size_t doesn't have to be as large as a pointer. It's perfectly ok
to have a computer with a 64-bit address space, in which every object
may be only 4 GB large. Then you would have sizeof(void *) == 8, and
sizeof(size_t) == 4.

Or take the old MS-DOS: sizeof(void *) == 4, sizeof(size_t) == 2.

Roland



More information about the M3devel mailing list