Mixed linking (C with F77)

Jonathan Leffler john at riddle.UUCP
Fri Jul 8 18:10:47 AEST 1988


In article <3670 at briar.Philips.Com> sxm at bebop.philips.com (Sandeep Mehta) writes:
>I cannot get to pass character strings from C to routines FORTRAN correctly
>(under UNIX) ?

If you have or can get hold of a Version 7 Unix Programmer's
Manual Volume 2, the article on ``A Portable Fortran 77
Compiler'' describes the interface between C and Fortran.

Quickly, when character strings are passed to Fortran, you have
to pass an extra argument, which is a long(!).  This extra
argument goes at the end of the list.  If there are several
strings, there is a length for each argument in left-right order.

Thus, if the FORTRAN would look like:

CALL fungus("abcdef", "xyzpqrzzz")

the C call would look like:

_fungus("abcdef", "xyzpqrzzz", 6L, 9L);

Try mailing me if you need more help.

Jonathan Leffler (john at sphinx.co.uk)	#include <disclaimer.h>



More information about the Comp.lang.c mailing list