Hello Bill,

In my experience, it is easier to to split the function into two pieces, a
pure C function and a thin XS wrapper. This makes it easy for other C code
to call the pure C version, while providing a Perl-accessible hook.

If you need to get that C function in XS code for an unrelated module, you
could try many approaches. One is to stash the pure C function's pointer in
an obfuscated package variable. Or you could try using ExtUtils::Depends.
Let me know if you need a bit more help as this is a little trickier.

If you want to call the xsub itself from another xsub, you'll need to
prepare the argument stack. I am pretty sure that this is just like calling
any other Perl function. For that, see details in perlcall:
http://perldoc.perl.org/perlcall.html

Finally, I wrote C::Blocks, which provides an entirely different approach
to this problem.

Hope that helps!
David

On Mon, Jun 12, 2017 at 9:05 AM, Bill Schoolfield <b...@billmax.com> wrote:

> Hi,
>
> Completely new to perlxs. So far I've managed to write a few c functions
> that work fine when referenced in perl. Now I need to call one of those
> functions from another c function. I assume that is possible and I assume
> the perl stack has to be used to make the call instead of the normal c
> conventions. Is this right?
>
> Can someone point me in the right direction on how to do this?
>
> Bill
>



-- 
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan

Reply via email to