Are uintptr_t and size_t same?

c++, casting, std, types

Solution

`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.

Problem

Possible Duplicate: size_t vs. intptr_t Some of my code deals with pointers and takes `uintptr_t` as input since it has to work with pointers. I now have to do the same thing with integers, So I want to reuse that code. Is `size_t` the same as `uintptr_t`? Can I change the implementation and use the same code for both pointers and integers just by replacing `uintptr_t` with `size_t`?

Original source

Related problems