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??? Thanks & Regards Sridevi -----Original Message----- From: Sisyphus [mailto:[EMAIL PROTECTED] Sent: Friday, October 13, 2006 4:29 AM To: Tallapragada, Sridevi; inline@perl.org Subject: Re: How to use Inline::Structs ----- Original Message ----- From: "Tallapragada, Sridevi" <[EMAIL PROTECTED]> To: <inline@perl.org> Sent: Thursday, October 12, 2006 11:44 PM Subject: How to use Inline::Structs > The following perl program doesn't work. I have copied this to temp.pl > and executed "perl temp.pl" > > use Inline C => Config => Structs => ['Foo']; > > my $obj = Inline::Struct::Foo->new; > $obj->num(10); > $obj->str("Hello"); > > myfunc($obj); > > __END__ > __C__ > > struct Foo { > int num; > char *str; > }; > > void myfunc(Foo *f) { > printf("myfunc: num=%i, str='%s'\n", f->num, f->str); > } > > OUTPUT : I get the following error > > Can't locate object method "new" via package "Inline::Struct::Foo" > (perhaps you forgot to load "Inline::Struct::Foo"?) at temp2.pl line 1. > I think you need to write it in a different format. (Even though that example is from the docs, I get exactly the same output as you.) The following rewrite works fine for me, however: ------------------------- use Inline C => <<'EOC', STRUCTS => 1; struct Foo { int num; char *str; }; typedef struct Foo Foo; void myfunc(Foo *f) { printf("myfunc: num=%i, str='%s'\n", f->num, f->str); } EOC my $obj = Inline::Struct::Foo->new; $obj->num(10); $obj->str("Hello"); myfunc($obj); ------------------------ All I've done there is just re-arrange the layout (which is the same as occurs in the Inline::Struct test files). And I also had to stick in the 'typedef struct Foo Foo;' Cheers, Rob