CKTIS / C
intptr_t — an integer type for holding pointers
An optional signed integer type from <stdint.h> supporting conversion of a valid void* pointer to an integer and back while preserving equality.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <stdint.h>
/* When INTPTR_MAX is defined: */
intptr_t saved = (intptr_t)pointer;
void *restored = (void *)saved;intptr_t is an optional signed integer typedef in <stdint.h>, excluding bit-precise integer types. Test availability with #ifdef INTPTR_MAX, not #ifdef intptr_t.
Its guarantee covers converting a valid void* to intptr_t and back to void*: the result compares equal to the original. The example keeps the object alive and leaves the saved integer unchanged.
uintptr_t provides the analogous guarantee as an unsigned type. Do not assume a particular width, support for function pointers, or that arithmetic on the saved integer corresponds to pointer arithmetic.
Examples
#include <stdint.h>
#include <stdio.h>
int main(void)
{
#ifdef INTPTR_MAX
int value = 42;
void *original = &value;
intptr_t saved = (intptr_t)original;
void *restored = (void *)saved;
printf("equal: %d\n", restored == original);
#else
puts("intptr_t unavailable");
#endif
return 0;
}
Result
equal: 1
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.