From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23902 invoked by alias); 29 Dec 2002 00:50:44 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 23895 invoked from network); 29 Dec 2002 00:50:43 -0000 Received: from unknown (HELO windlord.stanford.edu) (171.64.13.23) by 209.249.29.67 with SMTP; 29 Dec 2002 00:50:43 -0000 Received: (qmail 17178 invoked by uid 50); 29 Dec 2002 00:50:32 -0000 To: Gnu Compiler Collection Hackers Subject: Re: [GCC] Re: Bizarre warning about width of argument References: In-Reply-To: (Trevor Jenkins's message of "Sun, 29 Dec 2002 00:38:20 +0000 (GMT)") From: Russ Allbery Organization: The Eyrie Date: Sat, 28 Dec 2002 20:30:00 -0000 Message-ID: User-Agent: Gnus/5.090008 (Oort Gnus v0.08) XEmacs/21.4 (Honest Recruiter, sparc-sun-solaris2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-12/txt/msg01513.txt.bz2 Trevor Jenkins 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)