Subject: Re: Linking C & Fortran
From: "Ryan B. Caveney" <[email-masked]>
To: "Michael O'Melia" <[email-masked]>, <[email-masked]>
Date: Thu, 31 Aug 2000 14:11:51 -0400

----- Original Message -----
From: Michael O'Melia <[email-masked]>
To: <[email-masked]>
Sent: Thursday, August 31, 2000 12:28 PM
Subject: Linking C & Fortran

> I assume it is possible to link C and FORTRAN files.

Absolutely.  It's been a few years since I've done it, but it's quite
possible -- if you're careful.

> To do this requires some knowledge of the way variables
> are named and how the common blocks are to be used...

Also significant are argument-type conventions for functions.  In Fortran,
everything is pass-by-reference; in C, everything is pass-by-value by
default.  Another source of amusement is that Fortran strings are not
null-terminated; from the C point of view, every string argument must be
passed as *two* arguments: the string, and then its integer length.

> How is this done with Cygwin?

Same as for any other system, really.  EGCS includes g77 as well as gcc, and
the linker happily references libraries made of objects written in either
language with no special prompting.

> A code example for a C file
> calling FORTRAN and vice versa would be greatly appreciated.

Check out the source code for Octave (from your favorite GNU ftp mirror) --
it combines large amounts of C, C++ and Fortran, and builds happily under
Cygwin.

> Are there any compiler flags (special) needed?

Nope.  Have fun!

Ryan Caveney

--
Want to unsubscribe from this list?
Send a message to [email-masked]