dik@cwi.nl (Dik T. Winter) (05/25/88)
I know how to call C routines from Fortran programs on the systems I work on. What I want to know is if there are other systems that require other methods. The facts. Given a C routine: foo(a, n) int *a, n; that I want to call from a Fortran program as K = BAR(A, N) What should the interface routine (written in C) look like? The general Unix solution is: bar_(a, n) int *a, *n; { return(foo(a, *n)); } Another interface I have encountered is: BAR(a, n) int *a, *n; { return(foo(a, *n)); } Reading about the cdecl keyword on the net, I suspect tha Microsoft interface ought to be: cdecl int foo(); fortran int bar(a, n) int *a, *n; { return(foo(a, *n)); } (but correct me if I am wrong). And I know one system where I have to write: BAR(a, n) int a, n; { return(foo((int *)(a >> 16), *((int *)(n >> 16)))); } because addresses in Fortran and pointers in C are not aligned the same way. If you know other methods please mail me, I will summarise on the net. -- dik t. winter, cwi, amsterdam, nederland INTERNET : dik@cwi.nl BITNET/EARN: dik@mcvax