How to fix C error ‘unknown type name intptr_t’

Problem:

You have C code like

int v = 123;
intptr_t vptr = (intptr_t)&v;

but when you try to compile it you see an error message like

main.c: In function ‘main’:
main.c:5:1: error: unknown type name ‘intptr_t’; did you mean ‘__int128_t’?
 intptr_t vptr = (intptr_t)&v;
 ^~~~~~~~
 __int128_t
main.c:5:18: error: ‘intptr_t’ undeclared (first use in this function)
 intptr_t vptr = (intptr_t)&v;
                  ^~~~~~~~
main.c:5:18: note: each undeclared identifier is reported only once for each function it appears in

Solution:

Add

#include <stdint.h>

at the top of the source file where the error occured.