I\'m curious what the difference here is when typedefing an enum or struct. Is there any difference semantically between these two blocks?
This:
typ
The first form creates an anonymous enum type and creates a SomeEnum alias to it.
The second form creates both a enum SomeEnum type and a SomeEnum alias to it.
(In C, there are separate namespaces for types. That is, struct Foo is different from enum Foo which is different from Foo.)
This is more important for structs than enums since you'd need to use the second form if your struct were self-referential. For example:
struct LinkedListNode
{
void* item;
struct LinkedListNode* next;
};
typedef struct LinkedListNode LinkedListNode;
The above wouldn't be possible with the first form.