IV
, Perl's signed integer format, is guaranteed to be large enough to hold a pointer. intptr_t
is C's version of what Perl has had for a long time. (In fact, a ref is just a pointer stored in a scalar's IV slot with a flag indicating it's a reference.)
But you don't want to cast directly to an IV
as that can result in a spurious warning. As Sinan Ünür points out, use PTR2IV
instead.
IV
my_func()
myObjPtr self
CODE:
self = ...;
RETVAL = PTR2IV(self);
OUTPUT:
RETVAL
INT2PTR(myObjPtr, iv)
does the inverse operation.