in reply to Passing References to Arrays into Perl Extensions in C
Make your life simple:
write in Perl what is easy to do in Perl and write in C only what is easy to write in C. Then you can declare your XS code like:sub MyFunc { my $arrRef= shift(@_); my $packedArr= pack("f*",@$arrRef); return MyFuncC( 0+@$arrRef, $packedArr ); }
Note that this changes depending on the data type of the array to be used by the C function. Provide more details if you have questions.int MyFuncC( count, packedArray ) int count; char * packedArray; CODE: RETVAL= CFunc( count, (float *)packedArray );
Updated to work for floats.
- tye (but my friends call me "Tye")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: Passing References to Arrays into Perl Extensions in C
by Evanovich (Scribe) on Aug 03, 2001 at 19:23 UTC | |
by tye (Sage) on Aug 03, 2001 at 19:40 UTC | |
by Evanovich (Scribe) on Aug 03, 2001 at 19:53 UTC | |
by tye (Sage) on Aug 03, 2001 at 21:22 UTC | |
by tye (Sage) on Aug 04, 2001 at 02:05 UTC |