Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!ouroborous!limes From: limes%ouroborous@Sun.COM (Greg Limes) Newsgroups: comp.lang.c Subject: Re: compilers and linkers Message-ID: <33890@sun.uucp> Date: Fri, 13-Nov-87 19:34:29 EST Article-I.D.: sun.33890 Posted: Fri Nov 13 19:34:29 1987 Date-Received: Sun, 15-Nov-87 12:02:23 EST References: <2522@calmasd.GE.COM> Sender: news@sun.uucp Reply-To: limes@sun.UUCP (Greg Limes) Organization: Sun Microsystems, Mountain View Lines: 39 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. >how does one link C and or FORTRAN with Pascal? Peter, if C and FORTRAN globals did not get slightly different names, one might be tempted to assume that they used the same calling and storage conventions. In at least one FORTRAN compiler that I know of, parameters are passed by address to subroutines. Thus, if you call a FORTRAN subroutine from a C program, you have to pass pointers. Likewise, if your C routine is called by a FORTRAN routine, what you get is pointers to the FORTRAN parameters. Note that, in this case, the interface conversion burden is entirely on the C language. Thus, a C function callable by FORTRAN would be declared int foo_ (barp, bazp) int *barp; int *bazp; { } and would be called from fortran as: CALL _FOO (IBAR, IBAZ) Note the careful modification of the name "foo" so that each can talk to the other; the assembler thinks they are both using the global symbol "_foo_". ** You will probably have to contact a guru about your particular C, FORTRAN, and Pascal implementations. Be sure to ask him about nice things like naming of routines, calling sequences, return values, and so on. -- Greg [are we there yet?] Limes (limes@sun.com) DISCLAIMER: If I spoke for SUN, who would speak for me?