intptr_t --Signed integer type of pointer type size

intptr_t is a signed integer type with a pointer type size. For example, if the pointer type is a processing system expressed in 32 bits, it is defined as a 32-bit signed integer type, and if the pointer type is a processing system expressed in 64 bits, it is defined as a 64-bit signed integer type. intptr_t was introduced in C99.

Mutual type conversion with general-purpose pointer types

The intptr_t type is guaranteed to be interchanged with the general-purpose pointer type "void *". Bit representation does not change due to mutual conversion.

This is a sample program that converts intptr_t and void * to each other.

#include <stdint.h>

int main (void) {
  void * ptr;
  
  intptr_t iptr = (intptr_t) ptr;
  
  void * ptr_again = (void *) iptr;
}

Another use is the pointer type size unsigned integer type " uintptr_t".

Associated Information