This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Linking C & Fortran



----- Original Message -----
From: Michael O'Melia <mike.omelia@dynetics.com>
To: <cygwin@sourceware.cygnus.com>
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 cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]