[lug] [OT] more gcc queries

Daniel Webb lists at danielwebb.us
Sun Oct 10 20:03:56 MDT 2004


On Sun, Oct 10, 2004 at 07:50:03PM -0600, Daniel Webb wrote:

> #include<stdbool.h>
> void f(bool d);
> 
> int main(void)
> {
>   bool b = false;
>   f(b);
>   return 1;
> }
> 
> $ gcc -c -Wconversion test.c
> test.c: In function `main':
> test.c:8: warning: passing arg 1 of `f' with different width due to prototype
> $
> 
> Why?  The reference I'm using ("Expert C Programming" by var der Linden),
> says: "In ANSI C, arguments are not promoted if a prototype is used; otherwise
> they are."

(replying to myself)

I see that -Wconvert is actually talking about giving warnings if you do
anything different than the default type promotions.  So I still have the
problem: how can I get it to warn me about sending a float in a parameter that
should be char and so on?  The -Wconvert option seems to be made for people
who are converting K&R C to ANSI C, since K&R C always does type promotion on
function arguments, while ANSI C doesn't.

Can someone back me up, that gcc used to warn about mixing argument types
without the extra silly stuff given by the -Wconvert option?

Why isn't this option default any more?  What is the point of prototyping if
your compiler doesn't tell you when you're going against the prototype?

Daniel



More information about the LUG mailing list