Local struct in c

c

Solution

This is perfectly valid C89/C99/C11 code, this a structure with no tag and the object has block scope. Check C99 6.7.2.3p6 to see the identifier for the tag is optional.

Problem

If a struct is only used in one function, can I declare it in that function? Can I do this: ``` int func() { struct { int a, b; } s; s.a=5; return s.a; } ``` gcc choked on it, but it emitted a very weird looking error that I couldn't understand instead of saying "Sorry, you can't do that".

Original source