develooper Front page | perl.perl5.porters | Postings from July 2016

Re: substr as parameter to a XS sub

Thread Previous | Thread Next
Father Chrysostomos
July 4, 2016 15:25
Re: substr as parameter to a XS sub
Message ID:
Tony Cook wrote:
> Something like:
> T_PV
>         $var = (SvGETMAGIC($arg), SvOK ($arg)) ? ($type) SvPV_nomg_nolen($arg) : NULL
> should work.
> Use SvPV_nomg($arg, &PL_na) if you need to support perls older than 5.14.

Without the ampersand.  Also, SvGETMAGIC is not an expression, but a statement, in 5.14 and earlier.  If you want to support perl older than 5.16, you need to make it a separate statement:

        $var = SvOK ($arg) ? ($type) SvPV_nomg($arg, PL_na) : NULL;

(A typemap can be multiple statements, right?)

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About