Previous: Passing Numeric Arguments Up: Mixing Fortran and C

Passing Strings

Passing Fortran strings is quite a problem, since there is no standardization among vendors. The RTL currently supports six different methods of passing Fortran strings in arguments! Fortunately, the details of the six methods are hidden in the RTL Fortran String Conversion Routines, so they all look the same to the application programmer.

All code that passes a string to or from Fortran must use the RTL string conversion routines (the sfor2c and sc2for family). And, any code that calls the conversion routines must set the FTN_STRING flag in the imakefile. See Section , vimake, for details.

Although it is possible to treat the string in Fortran as a BYTE array rather than as a CHARACTER*n variable, thus bypassing the need for the string conversion routines, this is highly discouraged. It is non-standard Fortran to use BYTE arrays for string manipulation and should be avoided.

___________________________________________________

rgd059@ipl.jpl.nasa.gov