jettero has asked for the wisdom of the Perl Monks concerning the following question:
I've spent the last 3 hours reading basically the same informatoin in a dozen different tutorials.
I want to pass an array @a = (0.3, 0.2, 0.4) to a C function. Normally that's really easy:
That actuall turns into (in the .c):void something(a,b,c) double a double b double c
double a = (double) SvNV( ST(1) ); double b = (double) SvNV( ST(2) ); double c = (double) SvNV( ST(3) );
But what if the C library function expected an array of doubles (double *)? All I can think to do is make an array, and copy the data into it and pass that. Which is a waste, since the function something is obviously going to iterate over it again....
Is there any way to make the ST() argument stack look like a double *?
void something(array) double * array CODE: array = (double *) (MAJIK_STUFF(ST))
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: double array in XS
by tye (Sage) on Nov 02, 2000 at 21:36 UTC | |
|
Re: double array in XS
by fred (Acolyte) on Nov 02, 2000 at 19:58 UTC | |
|
Re: double array in XS
by Fastolfe (Vicar) on Nov 02, 2000 at 20:39 UTC | |
|
Re: double array in XS
by jettero (Monsignor) on Nov 02, 2000 at 21:32 UTC | |
by tye (Sage) on Nov 02, 2000 at 21:43 UTC |