From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12273 invoked by alias); 20 Feb 2002 12:36:47 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 12180 invoked from network); 20 Feb 2002 12:36:46 -0000 Received: from unknown (HELO greenius1.greenius.internal) (217.157.175.254) by sources.redhat.com with SMTP; 20 Feb 2002 12:36:46 -0000 Received: from greenius.co.uk (edmund.greenius.internal [10.0.0.110]) by greenius1.greenius.internal (8.11.2/8.11.2) with ESMTP id g1KCYcL11500 for ; Wed, 20 Feb 2002 13:34:39 +0100 Message-ID: <3C7397DE.8090304@greenius.co.uk> Date: Wed, 20 Feb 2002 05:35:00 -0000 From: Edmund Green User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.7) Gecko/20011221 X-Accept-Language: en-us MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: trying to use warnings effectivly Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-02/txt/msg00191.txt.bz2 I'm using gcc 2.96, and have read (and re-read) the info files so fear that I already know the answer to this question, but hopefully I'm wrong: Is there any way to selectivly disable or enable warnings for just parts of my C++ source/header files, or not give warnings for system includes? I would like to use the -Werror option on my code, but without this facility I am unable to do this without disabling a lot of warnings that I would like to keep enabled for the bulk of my code. There are actually two slightly different cases here. 1) System headers: I'm using a standard RedHat7.1 installation, on which many of the STL headers will give warnings regarding shadowed variables and signed/unsigned comparisons, which I would still like to be warned about in my own code (and also non-inlinable methods, but I can live without that warning enabled) If the compiler cannot do it then I suppose that I could process the output to strip warning lines generated by files in the system include directories, but it not quite as simple as just piping the output through grep because it is multi-line warnings like the following which I want to ignore: In file included from /usr/include/g++-3/string:6, from common/Defines.hpp:13, from common/anotherFile.hpp:8, from someSourceFile.cpp:12: /usr/include/g++-3/std/bastring.h: In method `basic_string &basic_string::replace (charT *, charT *, InputIterator, InputIterator)': /usr/include/g++-3/std/bastring.h:440: warning: declaration of `j1' shadows global declaration 2) Unused parameters: It would seem good practice to use the -Wunused-parameter most of the time, but it is often the case in callbacks and sometimes in virtual methods that there are going to be unused parameters. My understanding of the documentation is that I should be able to use the unused attribute to mark parameters which I know are not being used, but I have been unable to get this to work succesfully. can anybody show me where I'm going wrong on this example: // file Sample.cpp struct SomeObject; void myFunction(const SomeObject* __attribute__ ((unused)) anUnusedArg) { // dummy callback that doesn't use the argument } then compile with $ gcc -Wunused-parameter -c -o sample.o sample.cpp sample.cpp: In function `void myFunction (const SomeObject *)': sample.cpp:4: warning: unused parameter `const SomeObject *anUnusedArg'