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

前端 未结 2 1682

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

typedef long int                intptr_t;

is it supposed to be a type for integer or p

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-10 13:25

    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.

提交回复
热议问题