3 ms·
For block-scope declarations, it's not the definition but the initialization that you're thinking of. At least in C, every block-scope variable declaration is a
by LegionMammal978 4y ago
For block-scope declarations, it's not the definition but the initialization that you're thinking of. At least in C, every block-scope variable declaration is a definition:
> A definition of an identifier is a declaration for that identifier that:
> — for an object, causes storage to be reserved for that object; [...]
But initialization (in C) does not occur for block-scope objects without the optional initializer.
- stefncb 4y agoOkay, that's somewhat confusing. So a declaration is when the identifier enters the scope, and a definition is for a variable specifically. So a declaration that's not a definition could be a forward declaration for a function, or a typedef.
- LegionMammal978 4y agoYes, or the declaration of an extern variable.