On Wed, 14 Sep 2005, Sisyphus wrote:
> D:\test>dmake test
> D:\perl58_M\5.8.7\bin\perl.exe "-Iblib\lib" "-Iblib\arch" test.pl
> Undefined subroutine &Foo::foo called at blib\lib/Foo.pm line 8.
> BEGIN failed--compilation aborted at blib\lib/Foo.pm line 8.
> Compilation failed in require at test.pl line 3.
> BEGIN failed--compilation aborted at test.pl line 3.
> dmake:  Error code 255, while making 'test_dynamic'
> 
> If someone likes to play around with that and get it working (or confirm
> that it can't work), then I'd find that most interesting. However, now that
> I've switched to 'use subs' I don't actually *need* the 'use constant'
> construct ... so it's really just an academic exercise as far as I'm
> concerned.
> 
> Thanks for all the help, guys.
> 
> Cheers,
> Rob
> 
> D:\test>type Foo.pm

Try writing it like this:

    package Foo;
    use strict;
    use warnings;

    use Exporter;
    use DynaLoader;

    BEGIN {
        @Foo::ISA = qw(Exporter DynaLoader);
        @Foo::EXPORT_OK = qw(VALUE);
 
        $Foo::VERSION = '0.01';
 
        bootstrap Foo $Foo::VERSION;
    }

     use constant VALUE => foo();

     1;

I haven't actually tested this, so maybe I overlooked some other issue.
Let us know if it works! :)

Cheers,
-Jan

>     package Foo;
>     use strict;
>     use warnings;
> 
>     require Exporter;
>     require DynaLoader;
> 
>     use constant VALUE => foo();
> 
>     @Foo::ISA = qw(Exporter DynaLoader);
>     @Foo::EXPORT_OK = qw(VALUE);
> 
>     $Foo::VERSION = '0.01';
> 
>     bootstrap Foo $Foo::VERSION;
> 
>     1;
> D:\test>type Foo.xs
> #include "EXTERN.h"
> #include "perl.h"
> #include "XSUB.h"
> 
> #define VALUE 42
> 
> SV * foo() {
>      return newSViv(VALUE);
> }
> 
> 
> MODULE = Foo    PACKAGE = Foo
> 
> PROTOTYPES: DISABLE
> 
> 
> SV *
> foo ()
> D:\test>type Makefile.PL
> use ExtUtils::MakeMaker;
> 
> WriteMakefile(
>     NAME => 'Foo',
>     VERSION_FROM => 'Foo.pm'
> );
> D:\test>type test.pl
> use warnings;
> use strict;
> use Foo;
> 
> if(VALUE == 42) {print "ok 1\n"}
> else {print "not ok 1\n"}
> D:\test>


_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to