Pointers to Incomplete Types in Prototypes

Norman Diamond diamond at jit533.swstokyo.dec.com
Tue May 7 14:36:54 AEST 1991


In article <kre.673334440 at mundamutti.cs.mu.OZ.AU> kre at cs.mu.oz.au (Robert Elz) writes:

>Disclaimer: I know absolutely nothing about ANSI C ...

Well, a bit better than nothing.  I hope that your disclaimer hasn't
discouraged some other competent people from reading.

>I can't see how its possible for
>	type foo(struct bar *arg);
>to possibly be considered as any kind of a definition of the
                                            declaration
>struct tag "bar".  Whether "bar" is defined elsewhere or not,
                                     declared
>this is (and can only be) a reference to "bar".

The standard might have benefitted from distinguishing between tag
declarations and tag definitions, but it did not do so.

Anyway, when we adjust this statement to use the standard's words,
I think it is correct.

>Struct tags are (should be, surely) only [declared] in a context as
>	struct bar { ... };

As well as (SOMETIMES) in the vacuous case of
        struct bar;

>The question of the scope inside the function prototype can only
>possibly be relevant to names defined there, of which "bar" is not
>one in the above example.  It would be in
>	type foo(struct bar { ... } *arg);
>which would *always* be a meaningless prototype, regardless of
>whether bar was [declared] elsewhere or not.

Exactly.  (No other possibility, because
        type foo(struct bar;);
would be syntactically invalid.)

>It seems as if the compiler involved is treating the reference
>to bar in the first prototype above as a definition, as it hadn't
>seen a definition before.  That is surely a bug.

Yes.  No wonder I was dissatisfied with my previous posting on this
issue.  Something still seems wrong.
--
Norman Diamond       diamond at tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.



More information about the Comp.std.c mailing list