Fiftyvolts has asked for the wisdom of the Perl Monks concerning the following question:
I'm fairly experienced when it comes to creating XS interface to perl libraries, but this issue has confounded me for the past few days. I want to take advantage of the "INTERFACE:" directive in one of my XS files, but for some reason the generated C will not compile. I made a test module with only the barest of essentials as a sanity check, and I still couldn't get the thing to make. I'm not sure what I'm doing wrong; everything looks like it should according to the perlxs manual.
Any information on this is much appreciated :-) Below is the code int my Test.xs file
#include "EXTERN.h" #include "perl.h" #include "XSUB.h" int add_one(int i) { return i + 1; } int add_two(int i) { return i + 1; } MODULE = Test PACKAGE = Test int add_interface(i) int i INTERFACE: add_one add_two
the following is the error I get from cc during my make
cc -c -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -xO3 -xdepend -DV +ERSION=\"0.01\" -DXS_VERSION=\"0.01\" -KPIC -I/usr/perl5/5.6.1/lib/s +un4-solaris-64int/CORE Test.c "Test.c", line 34: syntax error before or at: cv "Test.c", line 45: type specifier can not be used as array size expres +sion qualifier "Test.c", line 45: warning: no explicit type given "Test.c", line 46: cannot recover from previous errors cc: acomp failed for Test.c *** Error code 2 make: Fatal error: Command failed for target `Test.o'
And finally here is the section of the generated C file it refers to
XS(XS_Test_add_interface) { dXSARGS; dXSFUNCTION(int); if (items != 1) Perl_croak(aTHX_ "Usage: Test::add_interface(i)"); { int i = (int)SvIV(ST(0)); int RETVAL; dXSTARG; XSFUNCTION = XSINTERFACE_FUNC(int,cv,XSANY.any_dptr); RETVAL = XSFUNCTION(i); XSprePUSH; PUSHi((IV)RETVAL); } XSRETURN(1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perlxs INTERFACE problem
by syphilis (Archbishop) on Nov 15, 2007 at 03:32 UTC | |
by Fiftyvolts (Novice) on Nov 15, 2007 at 12:37 UTC | |
by Fiftyvolts (Novice) on Nov 15, 2007 at 13:50 UTC | |
by syphilis (Archbishop) on Nov 15, 2007 at 13:01 UTC |