A typedef
needs a valid type. In the case of typedef struct Foo Foo
, it doubles as a forward declaration of struct Foo
, which satisfies the needs for the typedef
. In the case of typedef enum Bar Bar
, this doesn't work, since enum
s can't be forward declared.
Ref. eg. ISO/IEC 9899:1999 §6.7 :
A declaration specifies the interpretation and attributes of a set of identifiers. A definition of an identifier is a declaration for that identifier that:
— for an object, causes storage to be reserved for that object;
— for a function, includes the function body;98)
— for an enumeration constant or typedef name, is the (only) declaration of the identifier.
C++ has a similar constraint : Forward declaring an enum in c++.
It seems VS 2010 allows this as an extension.