Hi Tye, Yes, You are correct. Thanks. We have to copy the string (using XPUSH) into perl stack. Our problem will be like this, we have to call the perl subroutine with some 200 to 300 string of huge size during every invocation. Please see the below C code used to call the perl subroutine.
please note that the macros are not in the order. dSP; SAVETEMPS; PUSKMARK; XPUSHs(SV equivalent for the First string); XPUSHs(SV equivalent for the second string); : : : XPUSHs(SV equivalent for the Nth string); call_pv("pkg1::Process",G_SCALAR); something goes here
If we have something like passing the address of the strings as in the C calls
void Process(char *p) { // some processing } main() { char Str[500]; strcpy(Str,"slkdjaslkdjsljdlkjas"); Process(&Str);
Is there any way to push the address of the string using XPUSHs() and that string can be used by the perl script?. Regards, Poorna

In reply to Re: (tye)Re: Passing reference to perl from C code by Anonymous Monk
in thread Passing reference to perl from C code by Anonymous Monk

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.