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

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

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
December 31, 2016 14:48
Subject:
Re: [perl #130393] h2xs: Support for _Bool/stdbool.h?
Message ID:
CAHhgV8hmJ=f95yjXQMyLoTJw=9Ac9=wBDut=mQeHKGEn+T_eBQ@mail.gmail.com
On Sat, Dec 31, 2016 at 3:04 PM, Hugo van der Sanden via RT <
perlbug-followup@perl.org> wrote:

> On Wed, 28 Dec 2016 07:13:36 -0800, davem wrote:
> > 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)
>
> I'm seeing it output this (which I believe is correct):
> void
> h2xs(b)
>     _Bool   b
>
> >
> > 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))
>
> For me, xsubpp is giving this:
>
>     _Bool   b;
>
>     if (SvROK(ST(0)) && sv_derived_from(ST(0), "_Bool")) {
>         IV tmp = SvIV((SV*)SvRV(ST(0)));
>         b = INT2PTR(_Bool,tmp);
>     }
>     else [...]
>
> I haven't been able to reproduce the case of a missing '_Bool b'
> declaration in Foo.xs, so I'm stuck on this for now.
>
> Hugo
>

It seems to assume _Bool is some kind of object type, for some reason,
hence my previous suggestion for an explicit typemap.

Leon

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