Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c Subject: Re: Octal Date: Mon, 2 Jan 2017 14:15:21 +1300 Lines: 49 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net zkSwYPKBn2GcZ22BGpUKjgIlGehfeXwgFAaN35DiAGJT+30uIX Cancel-Lock: sha1:UGkFXGFxk7Ol9GU/LWEdzDs1ois= User-Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: Xref: csiph.com comp.lang.c:100846 On 01/ 2/17 01:53 PM, David Brown wrote: > On 01/01/17 21:38, Ian Collins wrote: >> On 01/ 2/17 09:11 AM, Stefan Ram wrote: >>> Ian Collins writes: >>>> On 01/ 2/17 08:54 AM, Stefan Ram wrote: >>>>> Ian Collins writes: >>>>>> I wonder why C hasn't adopted the simple rule from C++: if a parameter >>>>>> isn't going to be used, don't give it a name. >>>>> There's a style checker for C++ in clang, and when I write: >>>> It should be telling that control reaches end of non-void function... >>> >>> I was referring to »clang-tidy« with »-checks=* -Weverything -W >>> -Wall«. >> >> Note this is a guideline, not a language standard rule. >> >> If you refer to the relevant style guideline >> (https://google.github.io/styleguide/cppguide.html#Function_Declarations_and_Definitions) >> it includes the note: >> >> "Parameter names may be omitted only if the parameter is unused and its >> purpose is obvious." >> >> So clang-tidy is being over zealous. >> > > Warnings, especially those selected by flags like this, are always going > to be viewed differently by different people. /You/ think this > particular check is over zealous - other people think differently. Don't forget that this isn't a compiler warning: it is a style checker warning. As we all know, style is subjective. C++ specifically allows unnamed parameters for this very case, so the style warning is over zealous. > I am not sure when a parameter might be unnamed, unused, and it's > purpose obvious. The only case I can think of is when you are using one > of these single-item empty classes, like nothrow_t, or perhaps > operator++(int), where the parameter exists only to get the desired > overload. But maybe you are thinking of other examples? (Perhaps even > one relevant to C and not C++, but I'd be interested in C++ cases too.) The most common use case in C would be functions called through a table of pointers. In C++ it could also be a function called in a template. One example that comes to mind is something like an open function for a device where some devices use control flag parameter values and others don't. -- Ian