Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!nrl-cmf!ames!sdcsvax!sdcc6!sdcc19!sdcc15!gp3147 From: gp3147@sdcc15.UUCP (stockfisch) Newsgroups: comp.lang.c Subject: Re: compilers and linkers Message-ID: <387@sdcc15.UUCP> Date: Sat, 14-Nov-87 15:35:47 EST Article-I.D.: sdcc15.387 Posted: Sat Nov 14 15:35:47 1987 Date-Received: Sun, 15-Nov-87 20:13:04 EST References: <2522@calmasd.GE.COM> <33890@sun.uucp> Organization: University of California, San Diego Lines: 42 Summary: Greg Limes' followup is in error In article <33890@sun.uucp>, limes%ouroborous@Sun.COM (Greg Limes) writes: > In article <2522@calmasd.GE.COM> pal@calmasd.GE.COM (Peter Lawrence) writes: > >... C global names get an underscore prepended to them ... > >... FORTRAN global names get an underscore appended to them. And Fortran globals also get an underscore prepended. > >how does one link C and or FORTRAN with Pascal? > > ...In at least one FORTRAN compiler that I know of, parameters are > passed by address to subroutines. This is true of ALL Fortran compilers. > Thus, a C function callable by FORTRAN would be declared > > int > foo_ (barp, bazp) > int *barp; > int *bazp; > { > } If your C function has the synopsis int "foo( barp, bazp ) int barp, bazp;" then I would write an interface routine just like you have above, but then would add between the braces: return foo( *barp, *bazp ); > and would be called from fortran as: > > CALL _FOO (IBAR, IBAZ) This is completely wrong. Identifiers are not allowed to have underscores in Fortran. The underscore is not needed anyway, since the fortran compiler prepends and postpends an underscore. The C compiler prepends, so "foo_" in a C source is matched to "foo" in a Fortran source. All of this is for any UNIX(supply your own footnote) system, I couldn't say how universal it is otherwise. || Tom Stockfisch, UCSD tps@sdchemf.UCSD.EDU