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

Re: Correct way to access %^H from XS?

Thread Previous
July 11, 2016 22:27
Re: Correct way to access %^H from XS?
Message ID:
Maxwell Carey wrote:
>The cophh* functions have been available since 5.13.7, but they're still
>listed as experimental in the 5.24.0 docs. How likely are they to change or
>go away?

Pretty unlikely.  We should consider removing the experimental markings.
But even if they do later change, they're the right way to access
that now.  There isn't a non-experimental way to do this from XS.

>Is there any reason I can't just do the following?
> if (SvOK(bar))
>    printf("Value: %d\n", SvIV(bar));

The logic there is perfectly sane.  There is a problem with this code,
but it's shared with your existing code: SvIV() yields an IV value,
which is not necessarily the same type as int, which is what printf
needs for a %d.  You can definitely do

    if (SvOK(bar))
        printf("Value: %d\n", (int)SvIV(bar));


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