Structure pointer question
Doug Gwyn
gwyn at brl-smoke.ARPA
Sat Jun 11 19:17:11 AEST 1988
In article <361 at teletron.UUCP> andrew at teletron.UUCP (Andrew Scott) writes:
>Is it alright to #include "foo.h" and not "bar.h" in a source file if the
>fields of "struct bar" are not used?
Technically not, because the "struct foo" type remains incomplete until
you declare a complete type for "struct bar". The easiest thing to do
is to have "foo.h" include "bar.h" right after the incomplete "struct foo"
declaration. Then the application doesn't have to worry about it.
As you noticed, sometimes you can get away without doing it right.
More information about the Comp.lang.c
mailing list