[GCC] Re: Bizarre warning about width of argument

Trevor Jenkins trevor.jenkins@suneidesis.com
Sat Dec 28 19:50:00 GMT 2002


On Thu, 26 Dec 2002, Russ Allbery <rra@stanford.edu> wrote:

> Trevor Jenkins <trevor.jenkins@suneidesis.com> writes:
>
> > When the following example is compiled we get a warning:
>
> > foo.c: In function `foo':
> > foo.c:8: warning: passing arg 1 of `bar' with different width due to prototype
>
> > gcc -c -ansi -fno-nonansi-builtins -Wshadow -Wconversion foo.c
>

> The warning is correct for what -Wconversion is for.  You probably don't
> want to use this flag with regular programs.

Thank you; yes that fixed that issue with the test case. However, there is
another issue which can also be demonstrated with a near identical test
case:

#include <string.h>

void foo(unsigned short);
void bar(unsigned short);

void foo(unsigned short index)
{
bar(index);
}

void bar(unsigned short a)
{
}

the gcc options are slightly different but closer to those used in the
actual system:

gcc -c -fno-builtin -Wshadow foo.c

producing

riley.c:6: warning: declaration of `index' shadows global declaration
riley.c: In function `foo':
riley.c:7: warning: declaration of `index' shadows global declaration

The function "index" is not defined in the C standard. However, it is
mentioned in the string.h include file. So the question is how do we
suppress the warning for non-standard functions whilst retaining the
warning for functions defined in the standard?

Regards, Trevor

British Sign Language is not inarticulate handwaving; it's a living language.
Support the campaign for formal recognition by the British government now!
Details at http://www.fdp.org.uk/

-- 

<>< Re: deemed!



More information about the Gcc mailing list