Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c Subject: Re: Table of "safe" methods to suppress "unused parameter" warnings? Date: Mon, 31 Mar 2014 09:31:07 +1300 Lines: 36 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net W5P1AiHksLD4VL96rrJ7eg7JMhwj9Uwj8cWuJHvi+a133pJNRy Cancel-Lock: sha1:3Ocf/rX10YJWFl5eEL83Hn/TbkU= User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: Xref: csiph.com comp.lang.c:42366 Tim Rentsch wrote: > Ian Collins writes: > >> mathog wrote: >>> Sometimes the same parameter list must be passed to a lot of different >>> functions, and some of those will not use all of the parameters, >>> resulting in some compilers emitting "unused parameter" warnings. Here >>> are all of the methods I have found so far for suppressing these: >> >> I wonder why C doesn't just follow C++ and allow unnamed parameters? > > Assuming for the sake of discussion that C did this, it > still doesn't solve the problem, because sometimes you > want the parameter name there but still have it not used, > eg, when a function body has multiple definitions under > control of a C preprocessor conditional. I disagree. Allowing unnamed parameters would address the exact problem stated in the question. I don't see how multiple definitions under control of a C preprocessor conditional would make a difference. If an "unused" parameter is used in the function body, you have a bug waiting to happen. It would be better to have it unnamed to allow the compiler to spot the mistake. If you turn the argument on its head, why does C require parameters to be named? There doesn't appear to be any logical reason for this rule. > And there are > variables besides parameter names that are important to > mark UNUSED in certain circumstances. I assume you are referring to unused function return values? I don't see how this is relevant to the original question. -- Ian Collins