This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Request for compiler option to disable multiple declarations in a single statement
On 19/04/18 11:27, Manish Jain wrote:
>
> On 04/19/18 14:46, David Brown wrote:
>> Certainly it is heavily used in existing code - making an option
>> to disable it would be impractical.
>
> Thanks for replying, Mr. Brown.
>
> What I meant was if an option could be provided, existing code could
> compile without the option, and fresh code to compile with the switch
> enabled (as per user discretion, of course - no compulsion either way
> anywhere).
If it were an option for what code is acceptable, rather than a warning,
you would have trouble with header files that had multiple declarations
- it would quickly become unusable. A warning is much friendlier in
such contexts. (In particular, warnings like that are by default
disabled for system headers.)
>
> If the option garners wide recognition / usage, over a period of time
> the standard pointer declaration could be fixed to everyone's happiness:
>
> int* p; // which really is what it should be in all propriety
That is a /highly/ subjective view. I too prefer one declaration per
line in most cases, but I am not the only C programmer around - you
can't consider your personal opinion to be the only right one.
>
> The current declaration style really sickens me, particularly when
> trying to explain C pointers to others.
>
There is nothing to stop you using the style you want in the code you
write yourself. This warning would simply be a way to mark breaking a
code style guiderule.
It may be better implemented in a plugin, rather than in gcc itself.