andromedia33 has asked for the wisdom of the Perl Monks concerning the following question:
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'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl xs pass an array by reference
by bulk88 (Priest) on Dec 04, 2012 at 19:56 UTC | |
by andromedia33 (Novice) on Dec 06, 2012 at 20:48 UTC | |
by bulk88 (Priest) on Dec 06, 2012 at 22:05 UTC | |
by andromedia33 (Novice) on Dec 31, 2012 at 19:18 UTC |