Question about accessing global data from a line function
[email protected] (Perf Tech) Tue, 22 Nov 2016 23:29:55 -0600
| Newsgroups | perl.inline |
|---|---|
| Message-ID | <CAL27a14Y_nfkJERuqnuBVE=WObwMMqsBuqjWUquNdZ4s0EXXhA@mail.gmail.com> |
--f403045e21e0dd372e0541f12dba
Content-Type: text/plain; charset=UTF-8
Dear expert,
I am trying to access perl global variable ($data in this case) from
within a inline C function, but the "data" variable I used is not defined.
Any idea how to do it?
Thanks
Jin
$data = "this is a test";
test();
use Inline C => <<'END_OF_C_CODE';
void test() {
printf("here: %s\n", SvPV(data, PL_na));
}
END_OF_C_CODE
--f403045e21e0dd372e0541f12dba
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Dear expert,</div><div><br></div><div>=C2=A0 =C2=A0I =
am trying to access perl global variable ($data in this case) from within a=
inline C function, but the "data" variable I used is not defined=
.</div><div>Any idea how to do it?</div><div><br></div><div>Thanks</div><di=
v>Jin</div><div><br></div><div><br></div><div><div><span style=3D"backgroun=
d-color:rgb(255,255,0)">$data</span> =3D "this is a test";</div><=
div>test();</div><div><br></div><div>use Inline C =3D> <<'END_=
OF_C_CODE';</div><div><br></div><div>void test() {</div><div><span clas=
s=3D"gmail-Apple-tab-span" style=3D"white-space:pre"> </span>printf("h=
ere: %s\n", SvPV(<span style=3D"background-color:rgb(255,255,0)">data<=
/span>, PL_na));</div><div>}</div><div><br></div><div>END_OF_C_CODE</div><d=
iv><br></div></div></div>
--f403045e21e0dd372e0541f12dba--