2.45 Branch Created

Maciej W. Rozycki macro@orcam.me.uk
Fri Jul 18 14:30:23 GMT 2025


On Wed, 16 Jul 2025, Jan Beulich wrote:

> >>  Hmm, does our coding standard permit the use of local variable 
> >> declarations other than at the start of a block now?
> > 
> > We require C99, so yes.
> 
> 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.

  Maciej


More information about the Binutils mailing list