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); }

In reply to perlxs INTERFACE problem by Fiftyvolts

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.