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")In reply to (tye)Re: Passing References to Arrays into Perl Extensions in C
by tye
in thread Passing References to Arrays into Perl Extensions in C
by Evanovich
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |