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

Message-ID <4E28C926.B09@mindspring.com> (permalink)
Date 2011-07-21 20:49 -0400
From pete <pfiland@mindspring.com>
Organization PF
Newsgroups comp.lang.c
Subject Re: Not used parameter: how to disable the warning
References <j0a9jt$7f0$1@nnrp.ngi.it>

Show all headers | 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