Mail Archives: djgpp/2000/08/10/03:21:23
On Wed, 09 Aug 2000 19:19:02 -0400, "Lets Go Canes!"
<LetsGoCanes AT webmail DOT bellsouth DOT net> wrote:
> While compiling a program, I am getting some strange
> conversion warnings - I have -Wconversion enabled
> intentionally to catch unintended conversions.
>
> The following short sample will demonstrate:
>
> ----------
> void f(float, char);
>
> int main(void)
> {
> float x;
> char c;
>
> x = 22.0 / 7.0;
> c = '*';
>
> f(x, c);
> return 1;
>
> }
> ----------
>
> When compiled, it gives the following output:
>
> gcc -Wconversion -c test.c
> test.c: In function `main':
> test.c:11: warning: passing arg 1 of `f' as `float' rather than `double' due to prototype
> test.c:11: warning: passing arg 2 of `f' with different width due to prototype
> Any ideas?
The problem is that -Wconversion doesn't do what you think it does.
Please read the documentation. It says that -Wconversions warns if the
handling of the parameter would be different for a function *without*
prototype.
Thus, if you would pass your arguments to a function declared as
void ff();
then for ff(x,c) the first parameter 'x' would be converted to double
and the second parameter 'c' would be converted to 'int'. As you have
a prototyped function f and x,c exactly match the definition of the
prototype for f the handling of the parameters is *different* from the
handling for the call of ff. This is probably not useful for your
purpose but that's how it is defined.
Regards
Horst
- Raw text -