This is taken from an answer to a different question on SO:
A structure definition is private to a source file unless placed in a shared header file. No other source file can access the members of the struct, even if given a pointer to the struct (since the layout is not known in the other compilation unit).
If the struct needs to be used elsewhere, it must be used only as a pointer. Put a forward declaration of the form struct structname; typedef struct structname structname; in the headerfile, and use structname * everywhere else in your codebase. Then, since the structure members appear only in one source file, the structure's contents are effectively 'private' to that file.
This confuses me. Why can you only use pointers to a struct even if you include a header file that declares it (but does not define it)?
I mean, if I include a header that declares a function, a function which is defined in a separate implementation file, I can still access that function-- why are structs different? Why are their members private even if you can get to the declaration?