problem with call_external() [message #5129] |
Thu, 05 October 1995 00:00 |
chs11
Messages: 14 Registered: October 1995
|
Junior Member |
|
|
I'm trying to pass a two dimensional array of floats to an ansi C function.
I can successfully pass a 1-d array, but 2-d doesn't want to work.
Here's what I'm doing (in an abbreviated form)
;; idlprogram.pro ;;
pro idlprogram
a=fltarr(400,100)
b=fltarr(8)
m=long(400)
n=long(100)
l=long(8)
;some code to put data into a and b...
dummy = call_external('cfunc.so','_cfunc',a,b,m,n,l)
end
/* CFUNC.C
*/
void cfunc(int argc, void **argv)
{
float ** a;
float * b;
int m,n,l;
a = (float **) argv[0]; /* this doesn't work */
b = (float *) argv[1]; /* this works */
m = *(int *) argv[2];
n = *(int *) argv[3];
l = *(int *) argv[4];
/* code to printf a and b to stdout */
/* code to do something with a and b */
}
I'm running this on a sun4 as follows...
$ acc -fast -pic -c cfunc.c
$ ld -o cfunc.so -assert pure-text cfunc.o (and a custom library).a
$ idl
IDL> idlprogram
m = 400
n = 100
l = 8
b = 0.1, 0.2, 0.3, ...
a =
memory fault(coredump)
$
If anyone can help, I would be very grateful. Please email responces
to me (chs11@columbia.edu) and I will post a solution when one is found.
I appologize if this is a faq, but I don't know where to find the faq.
Carl
|
|
|