Mixed Labels and Declarations (Using the GNU Compiler Collection (GCC)) (original) (raw)
Next: C++ Style Comments, Previous: Case Ranges, Up: Other Extensions to C Syntax [Contents][Index]
6.12.13 Mixed Declarations, Labels and Code ¶
ISO C99 and ISO C++ allow declarations and code to be freely mixed within compound statements. ISO C23 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.