Undefined structures
Henry Spencer
henry at zoo.toronto.edu
Tue Feb 5 07:51:41 AEST 1991
In article <442 at newmedia.UUCP> jim at newmedia.UUCP (Jim Beveridge) writes:
> extern int callvw(struct _vw_package *pack);
>
>I find this rather amazing considering that "struct _vw_package"
>is undefined.
Not an issue. It is an "incomplete type", so there are vague restrictions
on doing certain things with it, but declaring pointers to incomplete types
is perfectly legal. The intuitive rule is that you can do anything that
doesn't require knowing the size or contents of the struct (unfortunately,
ANSI C phrases it in about that way, but doesn't bother saying precisely
where the size is needed).
This esentially means that all pointers to struct have to use the same
representation.
What GCC is trying to warn you about is that this incomplete type exists
only within that one declaration, meaning that there is no way to declare
anything else with the same type.
--
"Maybe we should tell the truth?" | Henry Spencer at U of Toronto Zoology
"Surely we aren't that desperate yet." | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list