Re: Loading/registering multiple xsubs

[email protected] (Jeffrey Ratcliffe)
Newsgroups perl.xs
Message-ID <CACg2wbwM4YrgJjMe_kc5EtNVj+u3AJT7WqKehu6-25XiQ-EqJw@mail.gmail.com>
On 12 October 2011 16:00, Torsten Schoenfeld <[email protected]> wrote:
> 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:

It didn't help - same error message.

In the end, I took the mechanism used in Win32::GUI, putting in lib/Foo.pm

sub bootstrap_subpackage {
    my($package) = @_;
    $package = 'Foo::' . $package;
    my $symbol = $package;
    $symbol =~ s/\W/_/g;
    no strict 'refs';
    DynaLoader::dl_install_xsub(
        "${package}::bootstrap",
        DynaLoader::dl_find_symbol_anywhere( "boot_$symbol" )
    );
    &{ "${package}::bootstrap" };
}

bootstrap_subpackage 'Bar';

Regards

Jeff
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.