C/Fortran mixed lang. problems...
voss at mdcbbs.com
voss at mdcbbs.com
Wed Apr 10 05:07:30 AEST 1991
I have been trying to call C routines from fortran under Ultrix
with little success in passing strings or returning an exit status.
>From what I could gather from the fortran documentation ( the section
is hopeless at best )and lots of trial and error, fortran passes strings
implicitly as (address,length) whereas C requires an explicit declaration
ie fortran call of C function :
status = str_func(str)
where the C function is declared as
integer str_func_ (str,str_len)
char *str;
int str_len;
Can anyone explain what is going on here ? Also, if the C function contains
a return statement to return say a status code, the character string str will
have garbage appended to it and variable status will not contain the correct
value. ???
Another interesting point I can't find a simple solution to is the fact
that the Ultrix fortran compiler appends an underscore to function names.
By doing so, how do you link with the standard C libraries which don't use
this convention ? I have been painfully writing little C functions that are
nothing more than shells around the standard routines but the names of these
shells have an underscore appended to their names. YUCH !!!
Some solid examples of mixed language programming under ultrix would be a
great benefit to understanding this stuff.
Any clues greatly appreciated.
Frank Voss
Husky Injection Molding Systems Ltd.
(416) 951 5000
More information about the Comp.lang.c
mailing list