function prototype problem

Alex Colvin mac3n at babbage.acc.virginia.edu
Sat Nov 19 02:05:48 AEST 1988


In article <8916 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
> In article <1736 at scolex> seanf at sco.COM (Sean Fagan) writes:
> >So, the moral of the story:  Don't pass in char's, short's, or float's to
> >your subroutines unless you want a Real(tm) ANSI C compiler to choke on it
> 
> No, that's the wrong moral.  The correct conclusion is that prototypes
> for old-style-defined functions must declare the parameters with the
> correctly widened types.

It's true.  Be careful declaring a (float) parameter in K&R C.  What
happens when you pass its address to something that expects (float *)?

Most stuff works OK when you're on a little-end address machine where the
beginning of (int) looks like (char).  Less common is where the beginning of
(double) looks like a (float).  Kids, don't try this on your big-end or
word addressed machines at home.  You'll get the wrong (char).

I understand that ANSI C may be an annoyance to those of you with VAXes, but I
can't afford one and it sure helps me.



More information about the Comp.lang.c mailing list