This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [GCC] Re: Bizarre warning about width of argument
- From: Russ Allbery <rra at stanford dot edu>
- To: Gnu Compiler Collection Hackers <gcc at gcc dot gnu dot org>
- Date: Sat, 28 Dec 2002 16:50:32 -0800
- Subject: Re: [GCC] Re: Bizarre warning about width of argument
- Organization: The Eyrie
- References: <Pine.LNX.4.44.0212290025470.30771-100000@suneidesis>
Trevor Jenkins <trevor.jenkins@suneidesis.com> writes:
> 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?
Compile with gcc -ansi (or gcc -std=c99 or something similar, or define
_POSIX_SOURCE or _XOPEN_SOURCE, or several other ways of accomplishing the
same thing). Then the system headers shouldn't expose those symbols. Of
course, then you won't be able to call non-standard functions at all.
This is the really annoying part of using -Wshadow, and is the reason why
I've considered stopping using it as a regular compile option when
building things in "all warnings" mode. It's not really clear how useful
-Wshadow is overall; most of the things it uncovers are completely
harmless, like using the names of standard functions as the names of
arguments in prototypes. Or things like using:
struct sockaddr_in sin;
in a file that for one reason or another includes math.h.
--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>