Passing Structures
IDL structure variables are stored in memory in the same layout that C uses. This makes it possible to pass IDL structure variables into CALL_EXTERNAL routines, as long as the layout of the IDL structure is known. To access an IDL structure from an external routine, you must create a C structure definition that has the exact same layout as the IDL structure you want to process.
For example, for an IDL structure defined as follows:
the corresponding C structure would look like the following:
typedef struct {
unsigned char zero;
IDL_LONG one;
float two;
double three;
short four[2];
} ASTRUCTURE;
Then, cast the pointer from argv to the structure type, as follows:
The following routine, found in incr_struct.c, increments each field of an IDL structure of type ASTRUCTURE. This is implemented as a function with a natural C interface, and a second glue routine that implements the IDL portable convention, using the one with the natural interface to do the actual work:
It is not possible to access structures with arbitrary definitions using the CALL_EXTERNAL interface. The system routine interface, discussed in Adding System Routines, does provide support for determining the layout of a structure at runtime.