C/FORTRAN intermixing problem

Scott Holt scott at prism.gatech.EDU
Sun Jan 20 06:31:01 AEST 1991


I am attempting to port a graphics library (di3000), written in FORTRAN,
which makes use of some C support routines. One of the C support routines
is used to return the value of an environment variable to the calling
FORTRAN routine; consequently, it calls getenv. The problem comes from
the fact that XLF provides a FORTRAN callable GETENV and, of course, 
programs get linked with the FORTRAN version. Thus, anything which calls
getenv, expecting it to come from the C runtine library, blows up.

Now, my first guess would be to simply replace the offending support
routine with a FORTRAN implementation wich calls the FORTRAN GETENV. 
This would result in a minimal number of changes to existing code. 
Unfortunately, there are a number of other support routines which call
getenv, expecting it to be from the C runtime library and they cannot
so easily be rewritten. So much for that.

Another (not so hot, but possible) option is to implement my own getenv
for the C code, name it something else (say Cgetenv) and replace all
the calls in to getenv in C code to calls to this routine. This would
be trivial if I had source to AIX 8-). 

Before I try to do this, I would like to know if there is an easier
way around my problem. I thought about simply yanking getenv.o and
whatever it needed from libc.a, but I don't see it there. Also, I am
not too sure what the implications would be for the version of GETENV
in the FORTRAN runtime library.

Basicly, what I would really like to find is a way to tell the loader
that one set of routines is to satisfy its external references from
the C runtine library, and another from the FORTRAN library. Any help
would be appreciated.

-Scott 



More information about the Comp.unix.aix mailing list