linking C and Fortran

der Mouse mouse at mcgill-vision.UUCP
Thu Aug 14 12:38:46 AEST 1986


In article <2668 at brl-smoke.ARPA>, moss at BRL.ARPA (Gary S. Moss (SLCBR-VLD-V)) writes:
> 	CC prepends an underscore to the function name, and F77 appends
> an underscore.  [Explanation, basically that f77 _forsub <-> C forsub_]

Well, I don't know what system you're on, but on all UNIX f77s I know
of, f77 appends an underscore and hands the result to the C compiler,
at least conceptually.  The result is that C ultimately prepends an
underscore and f77 *both* appends *and* prepends underscores.  The net
result is that what f77 knows as "forsub" is what C knows as "forsub_".

> Be sure to define/invoke the function from C with pointers (call by
> reference) exclusively.

Good point.  Also make sure the pointers point to something!  Probably
the commonest problem I see with pointers here is

	something *ptr;
	routine(ptr);

because they've been told that "routine" takes a "pointer to something"
as its argument.  They never notice that this pointer has to point to
a "something".
-- 
					der Mouse

USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: utcsri!mcgill-vision!mouse at uw-beaver.arpa

"Come with me a few minutes, mortal, and we shall talk."
			- Thanatos (Piers Anthony's Bearing an Hourglass)



More information about the Comp.unix.wizards mailing list