What is the uintptr_t data type?

c++, pointers, types

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

Problem

What is `uintptr_t` and what can it be used for?

Original source

Related problems