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


Groups > comp.lang.c > #8550

Re: Not used parameter: how to disable the warning

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: Not used parameter: how to disable the warning
Date 2011-07-22 10:47 +1200
Message-ID <98rokkFroiU5@mid.individual.net> (permalink)
References <j0a9jt$7f0$1@nnrp.ngi.it>

Show all headers | View raw


On 07/22/11 10:35 AM, 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 think it isn't because compiler warnings aren't regulated by the
> standard. 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?

Luckily neither of the compilers I use complain about the first form 
(with our without the unused; line).

I guess this points to another useful C++ feature that could easily be 
added to C (allowing an unused parameter name to be omitted):

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

-- 
Ian Collins

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


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