Messages in this thread | | | From | Andreas Schwab <> | Subject | Re: [Q] compiler no longer warning about undeclared struct? | Date | Thu, 28 Jul 2011 13:08:53 +0200 |
| |
Guennadi Liakhovetski <g.liakhovetski@gmx.de> writes:
> I always thought you need forward declarations for those, as in > > struct yy; > > before declaring struct xx above.
You only need that if you would otherwise introduce the struct tag in a different scope, like prototype scope (which ends at the end of the prototype).
>> Otherwise you could not define recursive structures as in >> ---- snip ---- >> struct a { >> struct *b; >> }; >> struct b { >> struct *a; >> }; >> ---- snip ---- > > I would add a "struct b;" forward declaration before "struct a".
You can do that, but since a struct definition doesn't introduce a new scope it is not necessary.
Andreas.
-- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different."
| |