in reply to Re^2: Accessing an XS function from a Perl function of the same name
in thread Accessing an XS function from a Perl function of the same name
Then, when you call foo(16) in perl, wrap_this_foo(16) is executed.int wrap_this_foo(int x) { return foo(x); }
If you comment out the the wrap_this_foo XS sub and re-run the script then you get:use strict; use warnings; use Inline C => Config => PREFIX => 'wrap_this_', BUILD_NOISY => 1, ; use Inline C => <<'END_C'; typedef int unbind; /* For this demo, we don't want foo * to bind to perl */ unbind foo(int x) { return x * 2; } int wrap_this_foo(int x){ return foo(x); } END_C print foo(16); # Outputs 32
I hope that proves that the original run was, in fact, calling wrap_this_foo and not directly calling the C function foo (which is invisible to perl).Undefined subroutine &main::foo called at try.pl line 25.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Accessing an XS function from a Perl function of the same name
by stevieb (Canon) on Mar 07, 2017 at 00:40 UTC |