in reply to Extending with C functions - some basic questions

Can I pass a reference to a string and have the C-library fill it for me so that I can de-reference it on return and get the string?

You don't need to take a reference first, just pass the string to your C function (think chomp). Your C function sees an SV* pointer and can directly modify the contents.

Also, no one has suggested Inline. Let me do so, it largely prevents you from having to use XS or mess with SWIG.

  • Comment on Re: Extending with C functions - some basic questions

Replies are listed 'Best First'.
Re^2: Extending with C functions - some basic questions
by unlinker (Monk) on Dec 18, 2010 at 05:31 UTC
    Yes, Inline is definitely more beginner-friendly that XS or SWIG and is something I plan to go with. However even for implementing integration with C libraries that require complex data structures or call-back pointers to be passed, a basic understanding of how Perl stores various data types is required. Could you point me to a beginner-friendly description of data structures used by Perl (things like SV* etc)? Thanks
      Could you point me to a beginner-friendly description of data structures used by Perl (things like SV* etc)?

      For me, the clearest description of Perl's data structures is PerlGuts Illustrated.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.