You can't use the struct _Struct
type member variable in the structure definition because it must be a complete type to do that. But struct _Struct
is not complete until the declaration's }
is met.
But for pointer we can do that because size of pointer is same be it a pointer to a complete type or incomplete one - so when compiler is reading them, it can decided it's size. (unlike the case where it is referring itself).
It has to be pointer not the structure itself because the type is not complete yet - it is not known what it's size will be.
Backing up what I said - From standard §6.7.2.1p3
A structure or union shall not contain a member with incomplete or function type (hence, a structure shall not contain an instance of itself, but may contain a pointer to an instance of itself), except that the last member of a structure with more than one named member may have incomplete array type; such a structure (and any union containing, possibly recursively, a member that is such a structure) shall not be a member of a structure or an element of an array.
Also when is it complete? From §6.7.2.1p8
The presence of a struct-declaration-list in a struct-or-union-specifier declares a new type, within a translation unit. The struct-declaration-list is a sequence of declarations for the members of the structure or union. If the struct-declaration-list does not contain any named members, either directly or via an anonymous structure or anonymous union, the behavior is undefined. The type is incomplete until immediately after the }
that terminates the list, and complete thereafter.
If anybody asks what is incomplete type for struct or union? From standard §6.2.5p22
A structure or union type of unknown content (as described in 6.7.2.3) is an incomplete type.
That is why the we cant use an instance of the struct which is being declared - because simply it's size is not possible to know.