ISO C99 and ISO C++ allow declarations and code to be freely mixed within compound statements. ISO C2X allows labels to be placed before declarations and at the end of a compound statement. As an extension, GNU C also allows all this in C90 mode. For example, you could do:
int i;
/* … */
i++;
int j = i + 2;
Each identifier is visible from where it is declared until the end of the enclosing block.
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Mixed-Labels-and-Declarations.html