Mixing ANSI and K & R 1 code.

karron at KARRON.MED.NYU.EDU karron at KARRON.MED.NYU.EDU
Sun Nov 18 02:57:39 AEST 1990


>>Seems you can't have newstyle argument lists (ANSI) receiving parameters
>>from old styles,non prototyped code.
>>
>>I first tried to write all my new stuff in ANSI code, but it would
>>always get float (Coord) arguments wrong.
>
>...
>
>>This is something that should be fixed.
>
>Fine, hop in your time machine, go back to the ANSI C meetings where
>they decided that if you have a routine declared with prototypes with
>arguments that are "float", that it really gets passed "float"s, not
>"double"s, and convince them otherwise.  That should fix it....
>
>If that's not possible, you're out of luck unless you can convince SGI
>or whoever to have "float" just mean "double", which is unlikely given
>the number of other things it'll probably break....
>
>If you have a routine that is to have prototypes, is to be passed
>floating-point arguments, and is to be called by old-style C, make its
>arguments "double" - even if that means not giving them type "Coord".
>

Sgi has make a weak attempt to address this "standard" problem. There is a
 cc -float flag to stop default promotion to doubles in argument/parameter
lists. Just seems not to work they way I hoped in spliced code...

I am not finished testing this out, so if anyone has any more insight, I
would like for you to speak up.

My design goal is to mix a library of K & R 1 code with ANSI C, and when the
K & R stuff is upgraded, not change my ANSI C code. I guess that there
is no performance penalty for passing by value floats as doubles, but I am
not certain of it. It is more bytes to push to the stack. Another suggested
solution is to make ANSI headers for K & R 1 code. This is a slippery issue
and I am not certain  about a robust answer. At least the run time code really
breaks when the problem arises ! (Only with floats).

Cheers!

dan.

+-----------------------------------------------------------------------------+
| karron at nyu.edu (mail alias that will always find me)                        |
|                                         Dan Karron                          |
| . . . . . . . . . . . . . .             New York University Medical Center  |
| 560 First Avenue           \ \    Pager <1> (212) 397 9330                  |
| New York, New York 10016    \**\        <2> 10896   <3> <your-number-here>  |
| (212) 340 5210               \**\__________________________________________ |
| Please Note : Soon to move to dan at karron.med.nyu.edu 128.122.135.3  (Nov 1 )|
+-----------------------------------------------------------------------------+



More information about the Comp.sys.sgi mailing list