foo* SvFoo(SV* foo) { SV* ret; IV tmp = SvIV((SV*)SvRV(foo)); ret = INT2PTR(foo*, tmp); }