Pointers to Incomplete Types in Prototypes

Mike Vermeulen mev at hpfcso.FC.HP.COM
Tue May 7 15:49:06 AEST 1991


>>You didn't say whether there was a prior incomplete decl.

> It does not matter.  According to my understanding of the standard and
> according to my ANSI C compiler the following is valid code:
> struct bar *getbar(int);
> void changebar(struct bar *, int);
>
> void main(void)
> {
>   struct bar *mybar;
>
>  mybar = getbar (1);
>  if (mybar)
>    changebar (mybar, 2);
> }

In the example above, the line "struct bar *getbar(int);" causes an incomplete
declaration of struct bar.  An earlier note complained about warning messages
from the HP ANSI C compiler.  However, in the example above, the HP ANSI C
compiler is silent because the incomplete declaration on the first line means
that the "struct bar" tag in the next line refers to "struct bar" at file
scope and not prototype scope.

--mev, mev at hpcomet

standard disclaimer: I speak for myself and not HP.



More information about the Comp.std.c mailing list