This is the mail archive of the
mailing list for the GCC project.
Re: Request for compiler option to disable multiple declarations in a single statement
- From: Manish Jain <bourne dot identity at hotmail dot com>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Thu, 19 Apr 2018 15:41:44 +0000
- Subject: Re: Request for compiler option to disable multiple declarations in a single statement
- References: <VI1PR02MB120069566F352087BFB27930F6B50@VI1PR02MB1200.eurprd02.prod.outlook.com> <CAH6eHdS_G+Lz8GRH6cGftiMEbb7=bqV8B2ivoVu2pHdnP=cVxw@mail.gmail.com>
> Wars have been fought over less.
I joined the list to make the request. So I just hope my war is not in a
lonely one-man army.
>> As for the problem of multiple declarations fraught in the suggestion
>> above, I would like gcc developers to please consider a compiler option
>> (--single-declarations perhaps) under which the programmer can only
>> introduce one declaration in one statement. If such an option could be
>> made available, it takes care of all declaration woes and lets declared
>> types bear close resemblance to what they appear to be from signatures.
> It might be appropriate as a warning option, for those who choose to
> enforce that style.
Fine - if anyone could create a warning specifically for multiple
declarations (and which can be turned into Werror such that it breaks
code for multiple declarations -- and absolutely nothing else), that
serves the purpose as well as an option like --single-declarations.
I don't even mind if programmers have to use pragma directives. The end
result I want is the programmer to have some way of getting the compiler
break code rather than compile the code at all. Right now, it is a real
mess that just builds on a simple oversight on the part of Dennis
Ritchie decades back. The most maddening way to address that mess is
drop the space between the asterisk and the pointer variable in a
declaration. Every single thing about pointer usage goes downhill from
that clumsy fix.
> And of course there are cases where avoiding multiple declarations
> changes the meaning of the code, such as this idiomatic C++:
> for (auto first = c.begin(), last = c.end(); first != last; ++first)
'idiomatic C++' looks more like 'idiotic C++' ever since v11/v14 came
out. Does Stroustroupe have nothing better to do these days than to make
a mockery of the once acceptable language ? I like C++ these days just
as a seafarer likes a close encounter with a shark.