in reply to Re^6: Inline CPP
in thread Inline CPP
On perl-5.8.8 that correctly outputs:use warnings; use Inline CPP => Config => BUILD_NOISY => 1; use Inline CPP => <<'EOC'; void add_nir(int x, int y, AV * perlList) { SV* perlItem=newSViv(2); av_push(perlList, perlItem); } EOC my @test = (1, 2); print "@test\n"; my $reftest = \@test; add_nir(1, 4, $reftest); print "@test\n";
and you can see that the "2" was, in fact, pushed onto the array. But, on perl-5.10.0 I get Can't locate auto/main/add_nir.al in @INC ... which is similar to what you are getting. Apparently, one can't supply an AV* arg to an Inline::CPP function on perl-5.10.0, though there's no such problem with perl-5.8.8. I don't know whether this is an Inline::CPP bug or a perl bug - probably Inline::CPP.1 2 1 2 2
At least that works fine for me on perl-5.10.0. Note that the perl code is exactly the same as in the first script. The only difference is in the way the add_nir() function has been constructed.use warnings; use Inline CPP => Config => BUILD_NOISY => 1; use Inline CPP => <<'EOC'; void add_nir(int x, int y, SV * perlList) { SV* perlItem=newSViv(2); av_push((AV*)SvRV(perlList), perlItem); } EOC my @test = (1, 2); print "@test\n"; my $reftest = \@test; add_nir(1, 4, $reftest); print "@test\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Inline CPP
by nirf1 (Novice) on Jun 03, 2008 at 07:32 UTC | |
by syphilis (Archbishop) on Jun 04, 2008 at 03:08 UTC |