On 12.10.2011 15:24, Jeffrey Ratcliffe wrote:
On 12 October 2011 13:11, Torsten Schoenfeld<[email protected]> wrote:
You have to call Foo_Bar.xs' BOOT section (which wires up the xsubs) from
Foo.xs' BOOT section. Look at Glib.xs' BOOT section for an example. For
Gtk2 and below, this is handled by Gtk2::CodeGen->write_boot.
Thank you for your quick response. I'm still struggling, so I made a
small example (attached), which fails to compile, trying to base the
boot mechanism on that in Glib:
foo.xs: In function 'void boot_Foo(PerlInterpreter*, CV*)':
foo.xs:18: error: expected unqualified-id before string constant
foo.xs:18: error: 'boot_Foo__Bar' was not declared in this scope
Looks like Glib's mechanism is not C++-safe: specifically, the "extern
XS" trick does not work because boot_Foo is already inside an <extern
"C"> section. Try this:
At the top of Foo.xs:
extern "C" XS_EXTERNAL (boot_Foo__Bar);
In its BOOT section:
_gperl_call_XS (aTHX_ boot_Foo__Bar, cv, mark);
If you want some backwards-compatibility, use
#ifndef XS_EXTERNAL
# define XS_EXTERNAL(name) XS(name)
#endif