Search code examples
c++pointerstypes

What is the uintptr_t data type?


What is uintptr_t and what can it be used for?


Solution

  • uintptr_t is an unsigned integer type that is capable of storing a data pointer (whether it can hold a function pointer is unspecified). Which typically means that it's the same size as a pointer.

    It is optionally defined in C++11 and later standards.

    A common reason to want an integer type that can hold an architecture's pointer type is to perform integer-specific operations on a pointer, or to obscure the type of a pointer by providing it as an integer "handle".