Mail Archives: djgpp/1997/09/30/21:40:19
On Tue, 30 Sep 1997, Mike Kretlow wrote:
> I have some f77 subroutines, which I like to call from my c program.
> I compiled the file sub.f with g77 under dos and the main c-program
> with djgpp 2, but the linker couldn't find the subroutines (I declared
> them of course as extern).
Normally, g77 (and many other compilers) names its subroutines in
lowercase letters appending an underscore to the name. Example:
in FORTRAN
SUBROUTINE SUB1(A,B,C)
DOUBLEPRECISION A
INTEGER B
CHARACTER*(*) C
END
It can be called from C like this
main()
{
double a_c;
int b_c;
char c_c[80];
sub1_( &a_c, &b_c, c_c, 80 ); // The last parameter is the length of the
// string c_c
}
Alexey
================================================================
Alexey Yakovlev, Quantum Chemistry Lab.
Boreskov Institute of Catalysis, Russian Academy of Sciences
pr. Lavrentieva 5, 630090 Novosibirsk, Russia
phone: +7-(3832)-350264, fax: +7-(3832)-355766 or 357687
e-mail: jack AT catalysis DOT nsk DOT su
================================================================
- Raw text -