Hi Rob, Thanks for your help! I want to send a reference to array (test) from perl :
my @test; my $reftest = \@test; add_nir(1,4,\$reftest);
and fill that array inside a cpp funcion (add_nir(..)). I followed your previous reply and I am using the perl guts :
int add_nir(int x, int y, AV** perlList ) { *perlList = newAV(); SV* perlItem=newSViv(2); av_push(*perlList, perlItem); ... }
I am using second layer references (pointer to pointer) because first level reference (see the difference in <AV* perlList> at the function declarations ):
int add_nir(int x, int y, AV* perlList )
didn't work. (after I filled the array in add_nir and left the function to it's caller, the array was empty - does the function
newAV()
allocates on the stack or the heap?) As i said the first level reference compiled but the array was empty on returning to the perl :first redirection level
my @test; add_nir(1,4,\@test); int add_nir(int x, int y, AV* perlList ) { perlList = newAV(); SV* perlItem=newSViv(2); av_push(perlList, perlItem); ...}
and the second level redirection couldn't be used : when running a test using my module I got the following error:
Can't locate auto/PM_wed/add_nir.al in @INC .....
What should I do ? Thanks, Nir

In reply to Re^6: Inline CPP by nirf1
in thread Inline CPP by nirf1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.