Mixed linking (C with F77)

Mike Lipsie mikel at pyrps5
Sun Jul 10 07:06:49 AEST 1988


In article <604 at riddle.UUCP> john at sphinx.co.uk (Jonathan Leffler) writes:
>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.

Additionally, it is important to remember that C and FORTRAN strings are
very different beasts.  A C string is a piece of memory terminated by
a null character while a FORTRAN string is a fixed piece of memory
which may or may not contain null characters.  Thus, in the example,
the two strings which look identical would have different actual
representations.

The example that Jonathan included (that I omitted for space reasons)
is valid only for one particular implementation (the standard VAX
UNIX compilers).  In general, interlanguage calling sequences are
not portable.
-----------
Mike Lipsie  {allegra,cmcl2,decwrl,hplabs,ut-sally,utzoo}!pyramid!mikel
Pyramid Technology Corp, Mountain View, CA  +1 415 965 7200 ext. 4980



More information about the Comp.lang.c mailing list