On Tue, 7 Nov 2000, Albert D. Cahalan wrote:

>          of a fixed point argument except when the same as the default
>          promotion.

<snip>

> The C language is crufty. In the absense of a prototype, "short" is
> promoted to "int". You wanted to be warned about that; you got it!

short going to int would be a default promotion and so shouldn't produce a
warning.

> To avoid the warning, avoid passing anything but "int" and "double".
> Maybe "long" is OK too, I forget.

No the secret is not to have any function arguments that aren't ints,
doubles etc. Its the cast from the default type on the stack to the non
default type to get in the function that produces the warning I think.

Take this example code:

void foo(int i);
void bar(short i);

int main() {
        short s;

        foo(s);
        bar(s);

        return(0);
}

void foo(int i) {
}

void bar(short i) {
}

When compiled with -Wconversion you get:

test10.c: In function `main':
test10.c:10: warning: passing arg 1 of `bar' with different width due to
prototype

Andrew



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to