----- Original Message ----- From: "Eric Wilhelm" <[EMAIL PROTECTED]>
.
.

IIRC, 'double *' is not a type that can be automatically mapped.  You
want to pass an array ref?  You'll either need to pass it as an SV and
manually unpack it, or use a typemap.

I think Eric has nailed it correctly.

If you need to be dealing with pointers to double in your C code, then here's one (not very sophisiticated) way of passing the double values between perl and C:

---------------------------------
use warnings;

use Inline C => Config =>
   BUILD_NOISY => 1;

use Inline C => <<'EOC';

void bar(double* x, double y) {
    *x += y;
}

void foo(SV * lon, SV * lat) {
    double d1, *dptr1, d2, *dptr2;
    dptr1 = &d1;
    dptr2 = &d2;
    d1 = (double)SvNV(lon);
    d2 = (double)SvNV(lat);
    bar(dptr1, 1.5);
    bar(dptr2, 2.7);
    sv_setnv(lon, *dptr1);
    sv_setnv(lat, *dptr2);
}

EOC

my $lon = 17.123;
my $lat = 15.5;

foo($lon, $lat);

print "$lon $lat\n";
---------------------------------

Note that bar() is accessible only from C - it can't be accessed from perl.
Note also that it won't work if bar() is defined below foo(). That is, bar() has to be defined in the C code *before* foo().
At least, that's the way it is for me.

Cheers,
Rob

Reply via email to