# from Joe Landman
# on Monday 21 August 2006 10:36 am:

>$x      = solve_for (@f,@k);

Firstly, that is going to pass a flat list:

  4.0, 3.0, 2.0 0.1, 0.2, 0.0, 0.0, 0.2, 0.3, 1.0, 1.0, 1.0 

(Aside:  unless you set a prototype of two array refs, but don't do 
that.)

But there is another problem:  the error you are seeing is because 
Inline doesn't grok this function signature.

>double *solve_for(double* f, double* k) {

What you probably want is to pass [EMAIL PROTECTED], and [EMAIL PROTECTED]  
But, that means you'll 
need to change the signature to get a pair of SV*'s and you'll then 
need to unpack them.

You also cannot return a pointer.

Here's a basic example of using array references.  There's more in the 
Inline::C-Cookbook.

#!/usr/bin/perl
use Inline C;

@inputArray = ( "134.3", "2.224", "3.343");
array_pass([EMAIL PROTECTED]);

__END__
__C__

int array_pass (SV* array_ref) {
  AV  *av_ptr;
  int n;

  if ( !SvROK(array_ref) || SvTYPE(SvRV(array_ref)) != SVt_PVAV )
    croak("Argument must be array reference");

  av_ptr = (AV*) SvRV(array_ref);
  printf("Number of elements: %d\n", 1+av_len(av_ptr));
}


--Eric
-- 
"...the bourgeoisie were hated from both ends: by the proles, because
they had all the money, and by the intelligentsia, because of their
tendency to spend it on lawn ornaments."
--Neal Stephenson
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to