Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've just finished doing some XSUB work, following along with the perlxstut manpage. After finishing, I attempted to add the named of some of the functions from the xs code to "all" EXPORT_TAG of the module. This does not seem to work. So if my xsub defined procedures a, b, and c neither adding qw(a b c) or qw(&a &b &c) seems to have any effect.

I have noticed that the h2xs-generated code contains a comment that says "Preloaded methods go here", but neither the perlxs or perlxstut talks about "preloading" - does this have anything to do with it?

Code below (with stuff renamed slightly).

Thanks, ---------
package toolong::totypeeverytime; use 5.008005; use strict; use warnings; use Carp; require Exporter; use AutoLoader; our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not expo +rt # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use foo ':all'; # If you do not need this, moving things directly into @EXPORT or @EXP +ORT_OK # will save memory. our %EXPORT_TAGS = ( 'all' => [ qw( a b c ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( ); our $VERSION = '0.01'; require XSLoader; XSLoader::load('foo', $VERSION); # Preloaded methods go here. 1;

Replies are listed 'Best First'.
Re: exporting subs from a .so
by Anonymous Monk on Aug 25, 2007 at 01:15 UTC
    package YourPackage; use XSLoader; use vars qw($VERSION @ISA); BEGIN { @ISA = qw( OnePackage OtherPackage ); $VERSION = '0.01'; # Put Perl code used in the BOOT: section here XSLoader::load 'YourPackage', $VERSION; } # Put Perl code making calls into XSUBs here # Put your Exporter stuff here