Are uintptr_t and size_t same?
size_t
has to be big enough to contain the size of the largest
possible object. uintptr_t
must be big enough to contain
any pointer. Given this, it is more or less guaranteed that
sizeof(uintptr_t) >= sizeof(size_t)
(since all of the bytes in
the largest possible object must be addressable), but not more.
On machines with linear addressing, they probably will be the
same size. On segmented architectures, on the other hand, it is
usual for uintptr_t
to be bigger than size_t
, since an
object must be in a single segment, but a pointer must be able
to address all of the memory.
It depends upon the implementation (and that includes the processor, the ABI, the compiler, the standard libraries). You have no guarantee that size_t
is the same as uintptr_t
; but that could happen (on 32 bits Linux x86 or ARM, both are 32 bits unsigned integers).
And the intent of size_t
is to be a size (notably of allocated memory chunks), while the intent of uintptr_t
is to be an unsigned integer of the same bit size as pointers.