Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site imsvax.UUCP
Path: utzoo!watmath!clyde!floyd!harpo!seismo!rlgvax!cvl!elsie!imsvax!harris
From: harris@imsvax.UUCP
Newsgroups: net.lang.f77
Subject: Answer to C functions in FORTRAN programs
Message-ID: <155@imsvax.UUCP>
Date: Mon, 6-Feb-84 10:31:36 EST
Article-I.D.: imsvax.155
Posted: Mon Feb  6 10:31:36 1984
Date-Received: Thu, 9-Feb-84 03:42:50 EST
Organization: IMS Inc, Rockville MD
Lines: 35


     I would like to thank all those who sent suggestions on how to call
C functions from FORTRAN programs.
I have included a solution for those who asked me for it.

Use f77 instead of ld.
Example:
	  f77 fprog.f cfunct.c


"fprog.f"

      integer a,b,c,addf
      a=3
      b=5
      c=addf(a,b)
      print*,c
      end


"cfunct.c"

addf_(ain,bin)
int *ain,*bin;
{
	int a,b,c;
	a = *ain;
	b = *bin;
	c = a + b;
	printf("%d\n",c);
	return(c);
}

The C function must have the "_" character appended.