----- Original Message ----- 
From: "Tallapragada, Sridevi" <[EMAIL PROTECTED]>
To: "Sisyphus" <[EMAIL PROTECTED]>; <inline@perl.org>
Sent: Friday, October 13, 2006 5:12 PM
Subject: RE: How to use Inline::Structs


> Hi Rob
>
> Thanks once again. I really appreciate your timely replies.
> I did add the typedef but still got the error.
>
> Now I am not getting the error as per your code change suggestions. I
> did take the same code as mentioned in your mail and it works.
>
> Here is another problem that I am facing. May be you can help me
> I have modified the code to include nested structures and it doesn't
> seem to work. Can you help??
> ------------------------------st.pl------------------------------------
> use Inline C => <<'EOC', STRUCTS => 1;
> typedef struct myst myst;
> struct myst{
>  int a;
> };
> typedef struct Foo Foo;
> struct Foo {
>   int num;
>   char *str;
>   myst myst[2];
>   Foo *next;
> };
>
>
> void myfunc(Foo *f) {
>   printf("myfunc: num=%i, str='%s  num1 = '%i' '\n", f->num, f->str,
> f->myst[0].a);
> }
>
> EOC
>
> my $obj = Inline::Struct::Foo->new;
> $obj->num(10);
> $obj->str("Hello");
> $obj->myst[0]->a(10);
>
> myfunc($obj);
> ------------------------------------------------------------------
>
> I get the following error
>
> perl st.pl
> /usr/bin/perl /usr/lib/perl5/5.8.5/ExtUtils/xsubpp  -typemap
> /usr/lib/perl5/5.8.5/ExtUtils/typemap -typemap
> /usr/lib/perl5/5.8.5/ExtUtils/typemap -typemap
> /root/sridevi/_Inline/build/st_pl_d994/Struct.map   st_pl_d994.xs >
> st_pl_d994.xsc && mv st_pl_d994.xsc st_pl_d994.c
> Error: 'Foo *' not in typemap in st_pl_d994.xs, line 220
> make: *** [st_pl_d994.c] Error 1
>
> A problem was encountered while attempting to compile and install your
> Inline
> C code. The command that failed was:
>   make > out.make 2>&1
>
> The build directory was:
> /root/sridevi/_Inline/build/st_pl_d994
>
> To debug the problem, cd to the build directory, and inspect the output
> files.
>
>  at st.pl line 1
> BEGIN failed--compilation aborted at st.pl line 19.
>
> ------------------------------------------------------------------------
> ---------
>
> When I opened the Struct.map file
> In the typemap section, I am able to see only ,struct myst and not
> struct Foo...
> "TYPEMAP
> struct myst *           O_OBJECT_myst"
>
> Why is that???
>

This module is apparently very buggy - perhaps to the point of unusability.
It hasn't been updated since 2003 - in fact I don't think Neil has updated
*any* of his modules in a long time. I think your best bet is to to do what
you want with Inline::C and forget about the neat tricks that Inline::Struct
is supposed to do for you.

As a further example of the bugginess of this module, this is what I get if
I replace 'myst myst[2];' with '/*  myst myst[2]; */':

D:\pscrpt\inline\struct>perl demo.pl
Can't use string ("/*  myst myst[2]; */") as an ARRAY ref while "strict
refs" in use at (eval 49) line 591.
BEGIN failed--compilation aborted at demo.pl line 20.

That happens before Inline::Struct even tries to compile the C code.
Apparently there's a problem separating the C code out from the perl code.
(I didn't realise it was *that* buggy.)

Perhaps these are bugs that can easily be fixed (though I have my doubts). I
don't have time to look right now. I'll probably look a little more closely
at it when I do get time .... in a day or 2 (or 3 :-)

Like I said, I think, given the apparent degree of bugginess of
Inline::Struct, that the best thing is to just use Inline::C. It will handle
structs fine.

Cheers,
Rob


Reply via email to