Structure pointer question
T. William Wells
bill at proxftl.UUCP
Wed Jun 29 13:23:12 AEST 1988
Having reread the new C standard just to see what it says about
incomplete types relating to structure pointers, here is what I
come up with.
There is nothing wrong with a source file like:
struct {
struct bar *ptr;
} x;
func()
{
void *vp;
vp = (void *)x.ptr;
vp = 0;
}
Nothing in the standard seems to require completing the type
unless the pointer is actually dereferenced.
Furthermore, since the assignments are valid (see 3.3.16.1), this
implies that the compiler knows the internal representation of
the structure pointer even if it does not know the contents of
the structure. There are only two ways that I can think of to
accomplish this: make all structure pointers equivalent or defer
code generation till link time. I would be extremely surprised
(read, "what reality are YOU in?") if they want to require the
latter, so it must be the former.
The C standard should make that explicit, don't you think?
More information about the Comp.lang.c
mailing list