I found some problem with definition of enum inside a struct, I want to have something like:
typedef struct
{
typedef enum { E1, E2, E3 } E;
E e;
} S;
in VS2012 I have errors:
error C2071: 'E' : illegal storage class
error C2061: syntax error : identifier 'E'
error C2059: syntax error : '}'
I found an explanation of C2071 but it is not the same case: http://msdn.microsoft.com/en-us/library/deb3kh5w.aspx
gcc-4.9 says:
error: expected specifier-qualifier-list before ‘typedef’
the interesting thing is that the code:
typedef enum { E1, E2, E3 } E;
E e;
works fine in global scope and in function's body.
I've also tried to do it without typedef, but unfortunately there are still lot's of errors:
error C2011: 'E' : 'enum' type redefinition
see declaration of 'E'
error C2208: 'E' : no members defined using this type
I found similar reason: http://msdn.microsoft.com/en-us/library/ms927163.aspx but I do define members of the type.
typedefin a structure declaration is a syntax error. What do you expect that code to do? If you want thetypedefvisible only inside the structure declaration (which isn't really useful anyway): Structure declarations don't introduce a new scope (and if they did, the enumeration constants would then be unreachable from outside the structure).