[net.lang.f77] Answer to C functions in FORTRAN programs

harris@imsvax.UUCP (02/06/84)

     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.