Article View: vmsnet.alpha
Article #77trouble passing functions between C and Fortran on Alpha/OSF
From: 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
Technical Details
Message-ID:
<1993Apr21.142748.20738@dxcern.cern.ch>Path:
arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!noc.near.net!uunet!mcsun!dxcern!burowShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10f8a1,de1519e0b183ed9b,start X-Google-Attributes: gid10f8a1,public X-Google-Thread: 1094ba,de1519e0b183ed9b,start X-Google-Attributes: gid1094ba,public X-Google-Thread: 10f594,de1519e0b183ed9b,start X-Google-Attributes: gid10f594,public X-Google-ArrivalTime: 1993-04-21 07:32:05 PST Newsgroups: vmsnet.alpha,cern.alpha,comp.lang.fortran Path: arc1-ca.pugleaf.net!gmd.de!newsserver.jvnc.net!howland.reston.ans.net!noc.near.net!uunet!mcsun!dxcern!burow From: burow@dxcern.cern.ch (Burkhard Burow) Subject: trouble passing functions between C and Fortran on Alpha/OSF Message-ID: <1993Apr21.142748.20738@dxcern.cern.ch> Organization: CERN European Laboratory for Particle Physics Date: Wed, 21 Apr 1993 14:27:48 GMT Lines: 50