🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.misc.discuss
Article #72465

Re: Will the object code from different languages be compatible?

#72465
From: Gregory A. Landrum
Date: Sat, 01 Feb 1992 19:29
35 lines
2638 bytes
In article <1992Jan28.212225.25601@CSD-NewsHost.Stanford.EDU>, 
amorgan@CS.Stanford.EDU (Crunchy Frog) writes:
> 
> a question.  Right now it is rather difficult to combine, say fortran code
> with C, or indeed any language with any other.  This means, for all practical
> purposes, that code must be written in one language only (ignoring cases
> like emacs).  Has any thought been given to the possibility of making the
> GNU language products (when they all come out) able to speak to one another?
> The idea being that I could write some code in C, some in Fortran, some in 

It is actually quite easy to use a combination of FORTRAN and C in a
single program.  I do it all the time. 
There are a couple of things that you have to keep in mind, however.
The two languages have different conventions for the types of function
arguments.  If you want to call f77 routines from C, you have to pass
pointers to everything that is not an array (fortran is call by
reference, while C is call by value). Also if you are passing
character strings to Fortran, you have to follow them with their
length.  
No amount of language standardization is going to fix these problems
(unless you completely redefine the languages) as they are inherent in
the calling models.
The other thing you have to do is affix an underscore to the end of
all the Fortran function names when you call them from the C part.
For example if you are calling the IMSL lmdif routine, you must have
lmdif_ in your C code.  This is pretty easy to do.  I guess that this
could be fixed in compilers (just don't have the f77 compiler stick
_'s onto function names), but there may be a reason for it.  
Any ideas?

Anyway, it really is easy to interface these two languages.

-greg
Senior Chemistry/Computer Science
Carnegie Mellon University
Technical Details
Message-ID: <UdWjIke00Voq8YY11N@andrew.cmu.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!ub!rutgers!rochester!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!gl10+
References: <1992Jan28.212225.25601@CSD-NewsHost.Stanford.EDU> <1992Jan30.152628.2222@wvnvms.wvnet.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1025b4,3e4536325cf8c41f
X-Google-Attributes: gid1025b4,public
X-Google-ArrivalTime: 1992-02-01 11:58:04 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!ub!rutgers!rochester!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!gl10+
From: gl10+@andrew.cmu.edu (Gregory A. Landrum)
Newsgroups: gnu.misc.discuss
Subject: Re: Will the object code from different languages be compatible?
Message-ID: <UdWjIke00Voq8YY11N@andrew.cmu.edu>
Date: 1 Feb 92 19:29:52 GMT
References: <1992Jan28.212225.25601@CSD-NewsHost.Stanford.EDU>
 <1992Jan30.152628.2222@wvnvms.wvnet.edu>
Distribution: gnu
Organization: Senior, Chemistry, Carnegie Mellon, Pittsburgh, PA
Lines: 35
In-Reply-To: <1992Jan30.152628.2222@wvnvms.wvnet.edu>