2.45 Branch Created
Maciej W. Rozycki
macro@orcam.me.uk
Fri Jul 18 14:58:27 GMT 2025
On Fri, 18 Jul 2025, Richard Earnshaw (lists) wrote:
> >> I actually think the two are separate from one another: We could certainly
> >> require C99 to use some, but not all of what it permits. Whether to allow
> >> declarations in the middle of statements is possibly worth a separate
> >> discussion (and I view this distinctly different from having decls in e.g.
> >> loop headers, where the variables then still have a pronounced scope).
> >
> > Exactly my point!
> >
> > For example glibc has required a C99 compiler since long before us, but
> > its coding standard not only allows the use of local variable declarations
> > other than at the start of a block, but it actually requires one to place
> > such declarations only at the first actual use of a variable, which may be
> > well into any block.
> >
> > Conversely the Linux kernel has also required a C99 compiler for a while
> > now, but its coding standard actually forbids the use of local variable
> > declarations other than at the start of a block.
> >
> > GCC and GDB have both long switched to C++ now, but they also have their
> > specific requirements beyond what the relevant standards say.
> >
> > So the requirements are really on a per-project basis and not necessarily
> > literally matching any ISO C (or C++) or POSIX standard revision.
>
> Any rule like this that can't be enforced by some other tools (eg the
> compiler or GNU indent) is always going to end up with missed cases.
> It's even worse when people work on multiple code bases with conflicting
> rules that have no common ground.
Fair enough.
> Is there real value to such a rule? If not, then I suggest we don't
> have one.
I have my personal preference, but I'm not going to argue either way
here. Also it's not up to me alone to decide. I'm fine with sticking to
whatever the chosen language standard allows.
FWIW,
Maciej
More information about the Binutils
mailing list