linking C and Fortran

Gary S. Moss SLCBR-VLD-V moss at BRL.ARPA
Thu Jul 31 02:47:09 AEST 1986


Bill,
	CC prepends an underscore to the function name, and F77 appends
an underscore.  So, to call Fortran from C, name the function _forsub in
the Fortran module, invoke it as forsub_ in the C module.  You may have
to shorten the name to allow for the extra characters, depending on your
linker.  Conversely, define it as forsub_ in the C module, and invoke it
as _forsub in the Fortran module.  Be sure to define/invoke the function
from C with pointers (call by reference) exclusively.

-moss.



More information about the Comp.unix.wizards mailing list