Structure pointer question

Andrew Scott andrew at teletron.UUCP
Thu Jun 30 05:01:30 AEST 1988


In article <389 at proxftl.UUCP>, bill at proxftl.UUCP (T. William Wells) writes:
> 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.
> 
> Nothing in the standard seems to require completing the type
> unless the pointer is actually dereferenced.

Now that my original question has been answered, I have another:

Suppose that I've constrcuted a library of functions that operate on a
"generic" data structure called 'struct message'.  This structure is an
incomplete type; the library functions merely deal with pointers to this
structure but not with the fields within.

It is now permissible to use this library with different declarations of
'struct message' *in the same program*?  I'm not planning on converting
between multiple kinds of "messages", I just want to have multiple modules
in the program able to use the previously constructed library with data
structures applicable to (and used in) only one module.

My initial guess is that it would work, given that C requires all structure
pointers to have the same format and provided that I compile the different
modules of the program seperately (so that the compiler doesn't see the
multiple declarations).
-- 
Andrew Scott		andrew at teletron.uucp    - or -
			{codas, ubc-cs, watmath, ..}!alberta!teletron!andrew



More information about the Comp.lang.c mailing list