delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/08/31/14:10:10

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-Id: <00a801c01376$eff71530$846c2b0a@saic.com>
Reply-To: "Ryan B. Caveney" <Ryan DOT B DOT Caveney AT saic DOT com>
From: "Ryan B. Caveney" <RYAN DOT B DOT CAVENEY AT saic DOT com>
To: "Michael O'Melia" <mike DOT omelia AT dynetics DOT com>,
<cygwin AT sourceware DOT cygnus DOT com>
References: <NDBBKMDOKLPHJBCNLABIGEGLCHAA DOT mike DOT omelia AT dynetics DOT com>
Subject: Re: Linking C & Fortran
Date: Thu, 31 Aug 2000 14:11:51 -0400
Organization: SAIC
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2314.1300
X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2314.1300

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019