Typedef is very useful for portable names, tag names (typedef struct foo Foo;
) and
keeping complicated (function) declarations readable (typedef int
(*cmpfunc
The offsetof() macro requires a structname and a membername, and thus cannot be used with inline struct definitions. Well, maybe on your implementation it can, but it isn't guaranteed by the C standard.
Update: As pointed out in the comments, this is possible:
struct blah { int a; int b; };
x = offsetof(struct blah, a); // legal
But inlining the struct definition is not:
x = offsetof(struct {int a; int b;}, a); // illegal
The former does not contain the keyword typedef, but inlining the struct definition is not possible either. Which version is indicated by "simple writing out the derived type" is unclear.