LINUX.ORG.RU

История изменений

Исправление hateyoufeel, (текущая версия) :

А зачем??? Указатель в число можно. А обратно по стандарту Си в любом случае UB.

По какому стандарту? Вот этому?

7.18.1.4
Integer types capable of holding object pointers
The following type designates a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer:

intptr_t

The following type designates an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer:

uintptr_t

Когда-нибудь я таки начну с ЛОРовских сишников брать деньги за чтение стандарта вслух, ведь сами они не могут.

Исходная версия hateyoufeel, :

А зачем??? Указатель в число можно. А обратно по стандарту Си в любом случае UB.

По какому стандарту? Вот этому?

7.18.1.4
Integer types capable of holding object pointers
1 The following type designates a signed integer type with the property that any valid
pointer to void can be converted to this type, then converted back to pointer to void,
and the result will compare equal to the original pointer:
intptr_t
The following type designates an unsigned integer type with the property that any valid
pointer to void can be converted to this type, then converted back to pointer to void,
and the result will compare equal to the original pointer:
uintptr_t

Когда-нибудь я таки начну с ЛОРовских сишников брать деньги за чтение стандарта вслух, ведь сами они не могут.