Thread View: vmsnet.alpha
1 messages
1 total messages
Started by Burkhard Burow
Wed, 21 Apr 1993 14:27
trouble passing functions between C and Fortran on Alpha/OSF
Author: Burkhard Burow
Date: Wed, 21 Apr 1993 14:27
Date: Wed, 21 Apr 1993 14:27
50 lines
2025 bytes
2025 bytes
I'm having trouble passing functions as arguments from C To Fortran routines
running:
DEC OSF/1 [RT] V1.2 (Rev. 10); Thu Apr 01 12:10:49 MET DST 1993
DEC OSF/1 V1.2 Worksystem Software (Rev. 10)
e.g. The following gives a segmentation fault when the Fortran routine 'e_'
is reached:
[Works fine under Ultrix, haven't checked elsewhere.]
#include <stdio.h>
int f_();
int e_(int (*u)());
int c(){ return 1;}
int d (int (*u)()) { return u();}
main()
{
printf("d (c ) returns %d.\n",d (c ));
printf("d (f_) returns %d.\n",d (f_));
printf("e_(c ) returns %d.\n",e_(c ));
printf("e_(f_) returns %d.\n",e_(f_));
}
integer function f()
f = 2
return
end
integer function e(u)
integer u
external u
e=u()
return
end
Note that C is able to pass the address of Fortran function to itself, but
can't pass an address of a function to Fortran.
I've looked in Bookreader, but wasn't able to find,
e.g. a Fortran Programmers Guide,
which usually includes section on mixing C and Fortran.
I've tried double indirection for passing the routine, as it is on the Apollo,
but it didn't help.
thanks,
burkhard burow@vxdesy.cern.ch
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads