in reply to Re^5: inline in a perl module
in thread inline in a perl module

I'd try the following:
# perl code here 1; __END__ # Documentation here __CPP__ // CPP code here // no END at the end.

Replies are listed 'Best First'.
Re^7: inline in a perl module
by nirf1 (Novice) on May 19, 2008 at 09:31 UTC
    Hi moritz, I thank you again for your efforts. I changes the order of those macros but it still gives me and error :
    cp lib/NewModule.pm blib/lib/NewModule.pm PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib/lib', 'blib/arch')" t/*.t t/NewModule....NOK 1# Failed test (t/NewModule.t at line 9) # Tried to use 'NewModule'. # Error: BEGIN not safe after errors--compilation aborted at /use +rs/nirf/perlTrials/NewModule/blib/lib/NewModule.pm line 12. # Compilation failed in require at (eval 1) line 2. # Looks like you failed 1 tests of 1. t/NewModule....dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 1 Failed 1/1 tests, 0.00% okay Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t/NewModule.t 1 256 1 1 100.00% 1 Failed 1/1 test scripts, 0.00% okay. 1/1 subtests failed, 0.00% okay. make: *** [test_dynamic] Error 2
    ***************** The NewModule.pm is : *****************
    package NewModule; use 5.008005; use strict; use warnings; use lib '/usr/lib/perl5/vendor_perl/5.8.0'; use lib '/users/nirf/perlTrials/cpanModulesInstallation/lib/perl5/site +_perl/5.8.0'; use lib '/users/nirf/perlTrials/cpanModulesInstallationInline/lib/perl +5/site_perl/5.8.5'; use Inline CPP => Config => INC => '-l/users/nirf/perlTrials/inlineExa +mple'; use Inline CPP => Config => MYEXTLIB => '/users/nirf/perlTrials/inline +Example/libmain.so'; use Inline CPP => Config => ENABLE => STD_IOSTREAM; use Inline CPP; require Exporter; 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 NewModule ':all'; # If you do not need this, moving things directly into @EXPORT or @EXP +ORT_OK # will save memory. our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( ); our $VERSION = '0.01'; + 1; __END__ __CPP__ + #include "main.h" int CCC; char GlobalArr[13] = {'G','l','o','b','a','l',' ','a','r','r','a',' +y','\0'}; MyClass myGlobalInstance(GlobalArr) ; int add(int x, int y) { char arr[7]={'i','n',' ','a','d','d','\0'}; MyClass mc(arr); myGlobalInstance.wow(); return x + y; } # Below is stub documentation for your module. You'd better edit it! =head1 NAME NewModule - Perl extension for blah blah blah =head1 SYNOPSIS use NewModule; blah blah blah =head1 DESCRIPTION Stub documentation for NewModule, created by h2xs. It looks like the author of the extension was negligent enough to leave the stub unedited. Blah blah blah. =head2 EXPORT None by default. =head1 SEE ALSO Mention other useful documentation such as the documentation of related modules or operating system documentation (such as man pages in UNIX), or any relevant external documentation such as RFCs or standards. If you have a mailing list set up for your module, mention it here. If you have a web site set up for your module, mention it here. =head1 AUTHOR Nir Frenkel, E<lt>nirf@localdomainE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2008 by Nir Frenkel This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available. =cut
      I changes the order of those macros
      But not in the way I suggested.

      And don't show us the code of the test outputs if the module doesn't even build - show us the the compilation error.

      Ok, so you try to compile your documentation as C++ code. Doesn't usually work, I think...

      I don't know that Inline stuff, but I bet there must be a way to tell it where the inlined code ends and your documentation starts. Or just throw that docs out, they aren't helpfull at all in this state.


      Search, Ask, Know