Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #8554

Re: Not used parameter: how to disable the warning

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date Thu, 21 Jul 2011 19:49:37 -0500
Message-ID <4E28C926.B09@mindspring.com> (permalink)
Date Thu, 21 Jul 2011 20:49:42 -0400
From pete <pfiland@mindspring.com>
Reply-To pfiland@mindspring.com
Organization PF
X-Mailer Mozilla 3.04Gold (WinNT; I)
MIME-Version 1.0
Newsgroups comp.lang.c
Subject Re: Not used parameter: how to disable the warning
References <j0a9jt$7f0$1@nnrp.ngi.it>
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Lines 45
X-Usenet-Provider http://www.giganews.com
NNTP-Posting-Host 4.156.228.164
X-Trace sv3-9dzNg0H/6A8qJNkcgvxB0N87yqVbooVGNzQfHqcl/4SnLnTg9j8g7bn73QHGp4ElgvHWuZ+NhrNlYD/!52EAuZz7GpQFeXcaY2/DiZcPymfr57BhsUVvsyM39ZH3QdJkyKitliIujstHwzO6xWWtitL9IKON!nnUtPBpyIw==
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 1960
Xref x330-a1.tempe.blueboxinc.net comp.lang.c:8554

Show key headers only | View raw


pozz wrote:
> 
> Is there a universal method
> (valid for all C compilers) that avoids the
> compiler to generate a warning
> about a not used parameter of a function?

I don't know.
 
> I think it isn't because compiler warnings aren't regulated by the
> standard.

That makes sense to me.

> So I'm wondering what could be the best or the better methods
> to face this situation.
> 
> I tried with the following on my compiler:
> 
>    int sum(int a, int b, int unused) {
>      unused;
>      return a + b;
>    }
> 
> but it works only with a low level of warnings. Otherwise I can do:
> 
>    int sum(int a, int b, int unused) {
>      unused = unused;
>      return a + b;
>    }
> 
> but it generates an unuseful instruction without optimization.
> 
> What do you use for that goal?

You could try:

int 
sum(int a, int b, int unused) 
{
    return unused, a + b;
}

-- 
pete

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Not used parameter: how to disable the warning pozz <pozzugno@gmail.com> - 2011-07-22 00:35 +0200
  Re: Not used parameter: how to disable the warning Ian Collins <ian-news@hotmail.com> - 2011-07-22 10:47 +1200
    Re: Not used parameter: how to disable the warning "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-07-22 02:13 -0700
    Re: Not used parameter: how to disable the warning Kenneth Brody <kenbrody@spamcop.net> - 2011-07-22 12:04 -0400
      Re: Not used parameter: how to disable the warning Ian Collins <ian-news@hotmail.com> - 2011-07-23 09:34 +1200
  Re: Not used parameter: how to disable the warning Harald van Dijk <truedfx@gmail.com> - 2011-07-21 16:06 -0700
  Re: Not used parameter: how to disable the warning pete <pfiland@mindspring.com> - 2011-07-21 20:49 -0400
  Re: Not used parameter: how to disable the warning Geoff <geoff@invalid.invalid> - 2011-07-21 17:52 -0700
  Re: Not used parameter: how to disable the warning Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-07-21 20:52 -0400
  Re: Not used parameter: how to disable the warning Seebs <usenet-nospam@seebs.net> - 2011-07-22 02:51 +0000
  Re: Not used parameter: how to disable the warning rudolf <r.thered@gmail.com> - 2011-07-21 20:08 -0700
    Re: Not used parameter: how to disable the warning Ian Collins <ian-news@hotmail.com> - 2011-07-22 15:15 +1200
  Re: Not used parameter: how to disable the warning Ralf Damaschke <rwspam@gmx.de> - 2011-07-22 09:01 +0000
  Re: Not used parameter: how to disable the warning Roberto Waltman <usenet@rwaltman.com> - 2011-07-22 17:56 -0400

csiph-web