From 0c6b4ad5fcacfc68fa914d9ba01ce5e107491198 Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Thu, 19 Feb 2026 22:43:04 +0100 Subject: [PATCH] doc: add narrow variable scope in loops to style examples --- doc/developer.texi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/doc/developer.texi b/doc/developer.texi index 3772dad698..fe08fb7fbd 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -225,6 +225,25 @@ AVStream *stream; AVStream* stream; @end example +@item +When sensible, prefer a narrow variable scope, especially in for loops: + +@example c, good +// Good +for (unsigned i = 0; i < submix->nb_elements; i++) @{ + // Do something... +@} +@end example + +@example c, bad +// Bad style +unsigned i; +//... +for (i = 0; i < submix->nb_elements; i++) @{ + // Do something... +@} +@end example + @end itemize If you work on a file that does not follow these guidelines consistently,