On this page
uintptr_t
Prev: uint64_t | Up: stdint.h | Next: PRIu64
Rel: stdint.h, stdint, stdbool & limits Guide
Ref: cppreference — uintptr_t
Tags: #public #prog #c #stdlib #stdint #tier/standard
Include
#include <stdint.h>
Signature & Overview
typedef /* unsigned ptr-width */ uintptr_t;
Unsigned integer guaranteed wide enough to hold a void * pointer round-trip.
Notes & Pitfalls
- Unsigned integer wide enough to hold any
void*pointer: Use for pointer-alignment math ((addr + align - 1) & ~(align - 1)) instead of casting pointers tolongorint.
Example
#include <assert.h>
#include <stdint.h>
int main(void) {
int x = 1;
uintptr_t addr = (uintptr_t)&x;
assert((int *)addr == &x);
}
Linked from
Related notes
- tuts/c/stdlib/stdint/PRIu64 Linked here; links to this page; shared tags: #c, #prog, #stdint, #stdlib, #tier
- tuts/c/stdlib/stdint/uint64_t Linked here; links to this page; shared tags: #c, #prog, #stdint, #stdlib, #tier
- tuts/c/stdlib/stdint Linked here; links to this page; shared tags: #c, #prog, #stdint, #stdlib
- tuts/c/stdlib/stdint_stdbool_and_limits Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdint/int32_t shared tags: #c, #prog, #stdint, #stdlib, #tier
- tuts/c/stdlib/stdint/int64_t shared tags: #c, #prog, #stdint, #stdlib, #tier
- tuts/c/stdlib/stdint/SIZE_MAX shared tags: #c, #prog, #stdint, #stdlib, #tier
- tuts/c/stdlib/stdint/uint32_t shared tags: #c, #prog, #stdint, #stdlib, #tier
- tuts/c/stdlib/stdint/uint8_t shared tags: #c, #prog, #stdint, #stdlib, #tier
- tuts/c/stdlib/assert/assert shared tags: #c, #prog, #stdlib, #tier