Hi Bruno, Bruno Haible via Gnulib discussion list <[email protected]> writes:
> In the Gnulib documentation, section "C99 features assumed by Gnulib", > we list: > > * A declaration after a statement, or as the first clause in a for > statement. > > The last compiler that did not support this was IRIX cc, which we don't > support for many years now. > > But, so far, we have not made much use of the opportunity of adopting > this C99 style. > > I plan to refactor the source code (excluding the one shared with glibc) to > - mix declarations and statements, so that variable declarations and > initializations get closer together, > - reduce the scope of local variables, > - use the common style of declaring a 'for' iteration variable > directly in the 'for' clause. > > The reason is that > - When reading code, the declarations of variables 20 or 50 lines > before their first use just feels inappropriate. > - It follows the more general principle > "Keep related things close together". > - See also this thread [1]. Sounds good to me. Can you use -Wshadow=local though when refactoring? I find code more difficult to understand with shadowed variables, which you can easily run into with variables used for loops. Collin
