in reply to Inline::C callbacks to Perl
the reference to the subroutine is being assigned to a temporary SV, which then goes out of scope (since it doesn't know the C program is still using it). Then when C tries to use it, the thing it was pointing to is no longer there.setCallback( \&calledBack );
So if you try this instead:
you should get the results you want, as the subroutine reference now exists in the still persistent, lexically-scoped "$psub" to which the SV "g_callback" points.my $psub = \&calledBack; setCallback( $psub );
It's a really good question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inline::C callbacks to Perl
by Animator (Hermit) on Nov 11, 2005 at 21:40 UTC | |
by BrowserUk (Patriarch) on Nov 11, 2005 at 22:52 UTC |