comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Passing Structures with Pointers with Call_External
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Passing Structures with Pointers with Call_External [message #40471] Tue, 10 August 2004 13:06
MajorSetback is currently offline  MajorSetback
Messages: 9
Registered: August 2004
Junior Member
I am using IDL Version 6.0 (linux x86 m32) on Red Hat Linux release 9.

I declare an array of structures thus.
function MakeFloatPlane,numrows,numcolumns
temp={Rows:long(numrows),Columns:long(numcolumns),Data:fltar r(numrows,numcolumns)}
return,temp
end

Planes=replicate(MakeFloatPlane(nY1,nX1),sNumberOfPlanes)

I then pass the array to C code through Call_External thus.
Result=Call_External('SharedLibrary.so','CFunction_cw',sNumb erOfPlanes,Planes,/unload)

The C code is as follows.
typedef struct FloatPlane_Struct
{
long Rows;
long Columns;
float **Data;
} FloatPlane;

extern "C" long CFunction_cw(int argc, void *argv[])
{
long lNumberOfPlanes;
FloatPlane *fppPlanes;
float *fpData;

lNumberOfPlanes=*((long *)(argv[0]));
fppPlanes=((FloatPlane *)(argv[1]));
fpData=((float *)(argv[3]));

fprintf(stderr, "lNumberOfPlanes=%d\n", lNumberOfPlanes);
fprintf(stderr, "fppPlanes->Rows=%d\n", fppPlanes->Rows);
fprintf(stderr, "fppPlanes->Columns=%d\n",
fppPlanes->Columns);
fprintf(stderr, "fppPlanes->Data=%d\n", fppPlanes->Data);
fprintf(stderr, "fpData=%d\n", fpData);
fprintf(stderr, "*fpData=%f\n", *fpData);

return 1;
}

I get the expected values for lNumberOfPlanes, fppPlanes->Rows,
fppPlanes->Columns, fpData and *fpData. However, I cannot interpret
the result I get for fppPlanes->Data.

If I add
fprintf(stderr, "fppPlanes->Data[0]=%d\n", fppPlanes->Data[0]);
idlde crashes, presumably due to a memory write error in the C code.
Is there any way to stop idlde crashing under such circumstances?

My main question is this. Is there a way to retrieve the IDL variable
Planes[i].Data within CFunction_cw?
[Message index]
 
Read Message
Previous Topic: histogram question
Next Topic: Re: IDLWAVE environment variables

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 06:19:41 PDT 2025

Total time taken to generate the page: 1.74972 seconds