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

Re: [perl #130393] h2xs: Support for _Bool/stdbool.h?

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
December 28, 2016 15:13
Subject:
Re: [perl #130393] h2xs: Support for _Bool/stdbool.h?
Message ID:
20161228151303.GK3096@iabyn.com
On Wed, Dec 28, 2016 at 05:37:04AM -0800, James E Keenan via RT wrote:
> On Wed, 28 Dec 2016 06:00:21 GMT, tauner@technikum-wien.at wrote:
> > 
> > h2xs -x booltest.h
> > So this might be a bug in C::Scan (which I have installed via cpanm
> > from HVDS/C-Scan-0.74)?
> > 
> 
> What happens if you do not use the '-x' option and thereby avoid C::Scan?
> 
> (When I did that, 'make' completed -- but since I've rarely attempted to write XS I don't know whether that's meaningful or not.)
> 
> Thank you very much.

When foo,h contains this:

    #include <stdbool.h>
    void h2xs(bool b);

then h2xs -x foo.h, via C::Scan, is generating an XS file that looks like:

    void
    h2xs(arg0)

which is being converted into the C code

    XS_EUPXS(XS_Foo_h2xs); /* prototype to pass -Wmissing-prototypes */
    XS_EUPXS(XS_Foo_h2xs)
    {
        dVAR; dXSARGS;
        if (items != 1)
           croak_xs_usage(cv,  "arg0");
        {

            h2xs(arg0);
        }
        XSRETURN_EMPTY;
    }

The issues seem to be that

1) h2xs and/or C::Scan isn't including the variable type for arg0 in the
generated XS; I assume that it should have output:

    void
    h2xs(bool arg0)

2) that ExtUtils/xsubpp isn't seeing that as an error and is instead
converting it onto invalid C code, by not including the line:

        bool	arg0 = (bool)SvTRUE(ST(0))
 

Does anyone here more familiar with XS want to comment?


-- 
Indomitable in retreat, invincible in advance, insufferable in victory
    -- Churchill on Montgomery

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About