It is a rather strange style to have a typedef inside a struct definition.
Typically, the only things that should appear between the { and } a struct definition are declarations of members of the structure.
As ouah says, an declaration in a struct definition cannot contain a storage class specifier; storage class specifiers typedef , extern , static , auto and register (and C11 adds _Thread_local ). This limitation makes sense, since the storage for the structure element is completely determined by the storage of the structure of which it is a member.
And typedef is a special case; it does not specify a storage class, but it is considered as a storage class specifier for syntax convenience.
You may have other types of declarations within the structure definition; for example, as you saw, you can nest a structure declaration inside another. For example, this program is valid (as far as I can tell):
struct outer { struct inner { int x; };
But gcc warns of a nested declaration:
cc:4:6: warning: declaration does not declare anything [enabled by default]
(And before I tried this, I would suggest that it is illegal.)
UPDATE : gcc -pedantic-errors rejects this with a fatal error, which indicates its illegality. I will try to check with the standard that it is illegal.
I think the best practice is to have only member declarations within the structure. If you need to declare a different type, declare it outside the structure declaration. For example, I would rewrite the code in the question as follows:
typedef struct Inner { int b; } INNER; typedef struct Outer { INNER inner; int a; } OUTER; int main(void) { OUTER obj; obj.a = 10; obj.inner.b=8; return 0; }
(Actually, I would write it like this:
struct inner { int b; }; struct outer { struct inner inner; int a; }; int main(void) { struct outer obj; obj.a = 10; obj.inner.b = 8; return 0; }