Array boundary checking & Fortran <> C translators

khb at chiba.kbierman khb at chiba.kbierman
Sat Feb 3 05:18:37 AEST 1990


In article <65973 at aerospace.AERO.ORG> tak at aerospace.aero.org (Michael L. Takayama) writes:

   If you are calling Fortran subroutines from C, you may want to be
   aware of the following problem which I ran into:

   In certain cases, floats do *not* pass correctly to REALs.  This
   problem does not occur with ints to INTEGERs nor with doubles to
   DOUBLE PRECISIONs.
....
   Maybe I am doing something illegal here and just got lucky with the
   ints and doubles passing correctly (I don't think so - I have
...

The problem is that K&R C implementations traditionally promote all
floats to doubles for both computational and parameter passing
purposes.

ANSI C "fixes" this, by allowing one to create function prototypes
which say explicitly what you want.

SunC (pre-ANSI) fixed this with a compiler option (dangerous, breaks
linkage to many basic C libraries) and via special macros for the C
programmer. 

Other vendors have provided other solutions over the years. Those
doing multi-lingual coding on Unix (pre V.4) may chose to work around
the issue by only attempting to pass double and integer data types
around. 

--
Keith H. Bierman    |*My thoughts are my own. !! kbierman at Eng.Sun.COM
It's Not My Fault   | MTS --Only my work belongs to Sun* kbierman%eng at sun.com
I Voted for Bill &  | Advanced Languages/Floating Point Group            
Opus                | "When the going gets Weird .. the Weird turn PRO"

"There is NO defense against the attack of the KILLER MICROS!"
			Eugene Brooks



More information about the Comp.sys.sgi mailing list