On Tue, Feb 14, 2006 at 12:12:01PM -0500, Guohong Hu wrote: > MaizeHi I am a new user of Inline. So could somebody help me here? > > I am trying to write a C subroutine with Inline. I want to pass the reference > of an array to the subroutine for calculation, and work on the values in the > array. The following is my code: > > > Thanks a lot, > Robbie
I havn't played with inline in a while but the below should work ok. use Inline C=>'DATA'; my @array = ( 1 .. 100 ); print get_an_element([EMAIL PROTECTED])."\n"; __DATA__ __C__ SV* get_an_element(SV* aref) { AV* array; if (! SvROK(aref)) croak("aref is not a reference"); array = (AV*)SvRV(aref); SV** v = av_fetch(array,8, 0); if( v == NULL ) croak("not enough elements in array"); SV* ret = *v; SvREFCNT_inc(ret); return ret; } -- The customer can count on us to globally utilize enterprise-wide data and assertively engineer scalable intellectual capital to stay competitive in tomorrow's world