Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: perlxs documentation

by Joost (Canon)
on May 26, 2005 at 09:36 UTC ( #460593=note: print w/replies, xml ) Need Help??


in reply to perlxs documentation

All the examples i've tried from perlxs, perlxstut, perlapi, perlguts and perlembed have been up-to-date for me (with various perl 5.8.x). Also the Extending and Embedding Perl book has been useful.

If you're worried about compatibility, take a look at Devel::PPPort.

Another way to use C code from perl is to use Inline::C or swig.

Replies are listed 'Best First'.
Re^2: perlxs documentation
by hotshot (Prior) on May 26, 2005 at 12:38 UTC
    All the examples i've tried from perlxs, perlxstut, perlapi, perlguts and perlembed have been up-to-date for me

    I tried running the example of Mytest that is given in perlxstut, the code generated for me was different than the onw they're talking about in the tutorial and I couldn't make it work.
      I hope you're refering to your local copy of perlxstut - the copies on perlmonks are out of date. But indeed, the files generated with perl 5.8.6 are slightly longer and have more options and comments in them than the docs show, though it's not too spectacular.

      I just tried the first example (adding the hello world function to the xs file) and it works fine for me. Here's what my Mytest.xs looks like (no changes required to any other file) update: I mean: just do what the tutorial says, and ignore small differences in the generated files compared to the docs:

      #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" MODULE = Mytest PACKAGE = Mytest void hello() CODE: printf("Hello, world!\n");
      and the test script:
      #!/usr/local/bin/perl use ExtUtils::testlib; use Mytest; Mytest::hello(); __OUTPUT__ Hello, world!
      You should probably remember that XS is whitespace sensitive, especially with regards to the function prototypes.

      HTH, Joost.

        the "hello world" worked for my just fine, it was indeed easy, the rest didn't, I'll check the whitespace sensativity thing you mentioned even though I think I did it ok.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://460593]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2020-12-02 19:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (44 votes). Check out past polls.

    Notices?