Hi there, forgive me for asking a really basic question; I tried my best without getting anywhere with Perl XS, and I'm hoping someone could help me out on this.
I basically tried to pass an array by reference to my C subroutine that takes a pointer to a double. Here's the c code and header I have:
========my c file==========end of c file=====#include "myfunction.h" double do_nothing(double *para) { return para[0]; }
===end of header file==double do_nothing(double *)
===============end of my xs file ======#include "myfunction.h" (and the rest of the XSUB header files) MODULE = Myfunction PACKAGE = Myfunction PROTOTYPES: ENABLE double do_nothing(x) double * x
=============end of typemap file=============double * T_SV
when I ran "make" it seemed fine. but when I tried to test my code by including the following command in my test file:
it failed, saying:my @array = (1.1,1.2); is(&myfunction::do_nothing(\@array),1.1);
got: '4.56890170385568e-317',
expected: '1.1'
In reply to perl xs pass an array by reference by andromedia33
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |