Xref: utzoo comp.lang.fortran:890 comp.lang.c:11188
Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!lll-tis!lll-winken!uunet!mcvax!ukc!reading!onion!riddle!john
From: john@riddle.UUCP (Jonathan Leffler)
Newsgroups: comp.lang.fortran,comp.lang.c
Subject: Re: Mixed linking (C with F77)
Message-ID: <604@riddle.UUCP>
Date: 8 Jul 88 08:10:47 GMT
References: <3670@briar.Philips.Com>
Reply-To: john@sphinx.co.uk (Jonathan Leffler)
Organization: Sphinx Ltd., Maidenhead, England
Lines: 23

In article <3670@briar.Philips.Com> sxm@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@sphinx.co.uk)	#include