Article View: fr.comp.lang.c
Article #15329Re: Eviter un warning
From: Anthony Fleury
Date: Thu, 29 Sep 2005 09:09
Date: Thu, 29 Sep 2005 09:09
58 lines
2631 bytes
2631 bytes
Harpo a �crit :
> Bonjour,
Bonjour,
> J'ai des fonctions dont la d�claration d�pend de l'API qui r�git la
> mani�re dont elles sont appel�es et il arrive parfois que je ne me
> serve pas d'1 argument :
> Exemple :
> int incr( int blah, int i )
> {
> return ++i;
> }
> Le compilateur (GCC avec la conjugaison des options -W et -Wall) me
> signale :
> Warning: unused parameter 'blah'
[...]
> Une solution serait de supporter ces warnings (ce qui ne me plait gu�re)
> et d'�ter l'option -W dans la distribution source (ce qui ne me plait
> gu�re plus).
[...]
> Quelqu'un connait-il une meilleure solution ?
En plus des solutions donn�es par les deux autres contributeurs, j'ai la
solution GCC : utiliser -Wno-unused.
J'avais trouv� cette solution tr�s pratique notamment quand je faisais
de la programmation syst�me sous unix/linux, dans la fonction de gestion
des signaux on n'a pas tout le temps besoin du num�ro du signal �mis...
> gcc --version
gcc (GCC) 3.4.2 [FreeBSD] 20040728
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> more test.c
int f(int a) {
return 0;
}
int main(int argc, char** argv) {
f(0);
return 0;
}
> gcc -W -Wall -ansi test.c -o test
test.c:1: warning: unused parameter 'a'
test.c:5: warning: unused parameter 'argc'
test.c:5: warning: unused parameter 'argv'
> gcc -W -Wall -ansi -Wno-unused test.c -o test
>
--
Anthony Fleury
Technical Details
Message-ID:
<433baf52$0$22425$626a14ce@news.free.fr>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!infeed-2.proxad.net!news18-e.free.fr!not-for-mailReferences:
<433b8a93$0$17226$8fcfb975@news.wanadoo.fr>Show Full Headers
Complete Article Headers
X-Google-Thread: f9822,79548392e83a3222 X-Google-Attributes: gidf9822,public X-Google-Language: FRENCH,ASCII Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!infeed-2.proxad.net!news18-e.free.fr!not-for-mail Date: Thu, 29 Sep 2005 11:09:42 +0200 From: Anthony Fleury <fleury_anthony@_hotmail.com_> Reply-To: fleury_anthony@hotmail.com User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: fr, en MIME-Version: 1.0 Newsgroups: fr.comp.lang.c Subject: Re: Eviter un warning References: <433b8a93$0$17226$8fcfb975@news.wanadoo.fr> In-Reply-To: <433b8a93$0$17226$8fcfb975@news.wanadoo.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Lines: 58 Message-ID: <433baf52$0$22425$626a14ce@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 29 Sep 2005 11:09:38 MEST NNTP-Posting-Host: 82.236.54.18 X-Trace: 1127984978 news18-e.free.fr 22425 82.236.54.18:1188 X-Complaints-To: abuse@proxad.net