In article <>
CptDondo <> writes:
>I'm trying to figure out some code that uses structures, structures, and
>more structures...
>
>It's a bit of rat's nest, and I'm having some trouble sorting it all out.
>
>The authors use a lot of the following 'declarations' in the various .h
>files:
>
>struct document;
>struct document_view;
>struct link;
>struct session;
>struct term_event;
>struct terminal;
>struct uri;
>struct conv_table;
>
>These aren't being used as a part of another structure; they're just
>standalone declarations? statements?
They are incomplete types. Usually, the reason for putting those
in is that something in the file declares a pointer to one of them:
struct foo;
void useFoo(foo *fooPtr);
The compiler doesn't need the detail of the struct to deal with a
pointer. Any file that uses the fields inside these structs will
need a complete type defined.
Some libraries use this for encapsulation -- they give you a pointer
that you send back in every call, but no one outside the library
looks inside the struct.
>I can't quite picture what these do.
>
>What exactly would be the effect of those empty declarations?
They tell you, "These types exist and you don't need to know what
is inside them."
--
Drew Lawson | "But the senator, while insisting he was not
| intoxicated, could not explain his nudity."