Subject: Re: C Language Standard(s)
To: matthew green <mrg@mame.mu.OZ.AU>
From: Simon J. Gerraty <sjg@frodo.dn.itg.telecom.com.au>
List: current-users
Date: 12/22/1995 11:47:28
> foo(bar, baz)
> char bar;
> int baz;
> {
> short what_i_want = baz;
>
> then all compilers will do the right thing and your code will work as
> you expected.
>
> except i'll have to cast call the calls to foo() with an
> (int). of course i think this is a bad idea.
But that is exactly what happens at the function itself anyway.
A K&R compiler will automatically cast sub-int objects to int.
An ansi compiler will pass a short if that is what the prototype says,
but then your codes is going to behave differently depending on what
you compile it with - sub-optimal.
If you want to retain support for old-style function definitions, then
all args should be int or larger. Anything else can produce strange
results.
--sjg