Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is intptr_t,is it a type for integer or pointer?

Tags:

c

linux

It's defined in /usr/include/stdint.h:

typedef long int                intptr_t;

is it supposed to be a type for integer or pointer?

like image 426
compile-fan Avatar asked Jun 20 '11 11:06

compile-fan


People also ask

Is Uintptr_t a pointer?

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.

Where is intptr_t defined?

It's defined in /usr/include/stdint.


2 Answers

It is a signed integer type that is big enough to hold a pointer.

like image 82
Richard Pennington Avatar answered Sep 25 '22 01:09

Richard Pennington


It is a signed integer type that guaranteed to can hold a void* type.

And why there is also [u]intptr_t? Because:

Any valid pointer to void can be converted to intptr_t or uintptr_t and back with no change in value. The C Standard guarantees that a pointer to void may be converted to or from a pointer to any object type and back again and that the result must compare equal to the original pointer. Consequently, converting directly from a char * pointer to a uintptr_t is allowed on implementations that support the uintptr_t.

like image 31
the kamilz Avatar answered Sep 25 '22 01:09

the kamilz