next up previous 252
Next: The IMPORT and EXPORT Macros
Up: More on Arrays
Previous: Arrays of pointer to char


POINTER Arrays

An array of pointers would need to be converted back and forth between the C and FORTRAN representations to cope with the possibility that the length of a C pointer is not the same as the length of a FORTRAN INTEGER. This can be done by declaring a suitably-sized FORTRAN array and converting each element using either cnfCptr or cnfFptr, according to the direction of conversion.

For example, to call a FORTRAN subroutine which returns an array of three pointers to real, the C code would need to be something like:

F77_REAL_TYPE * pntr[3]
DECLARE_POINTER_ARRAY(fpntr,3)

F77_CALL(getptr)(POINTER_ARRAY_ARG(fpntr))
/* Import the pointers to C */
for (i=0;i<3;i++) pntr[i]=(F77_REAL_TYPE *)cnfCptr(fpntr[i]);

See also The IMPORT and EXPORT macros.



next up previous 252
Next: The IMPORT and EXPORT Macros
Up: More on Arrays
Previous: Arrays of pointer to char

CNF and F77 Mixed Language Programming -- FORTRAN and C
Starlink User Note 209
P.M. Allan
A.J. Chipperfield
R.F. Warren-Smith
19 January 2000
E-mail:ussc@star.rl.ac.uk