From: Russ Allbery <rra@stanford.edu>
To: Gnu Compiler Collection Hackers <gcc@gcc.gnu.org>
Subject: Re: [GCC] Re: Bizarre warning about width of argument
Date: Sat, 28 Dec 2002 20:30:00 -0000 [thread overview]
Message-ID: <yllm298x7r.fsf@windlord.stanford.edu> (raw)
In-Reply-To: <Pine.LNX.4.44.0212290025470.30771-100000@suneidesis> (Trevor Jenkins's message of "Sun, 29 Dec 2002 00:38:20 +0000 (GMT)")
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/>
prev parent reply other threads:[~2002-12-29 0:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-27 3:31 Trevor Jenkins
2002-12-27 3:37 ` Russ Allbery
2002-12-28 19:50 ` [GCC] " Trevor Jenkins
2002-12-28 20:30 ` Russ Allbery [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yllm298x7r.fsf@windlord.stanford.edu \
--to=rra@stanford.edu \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).