* Anton Altaparmakov (ai...@ca...) [20040229 18:30]:
> Unnamed structs and unions are damn nice C feature and I can't
> understand why the gcc mob don't just support them straight out.
Please don't start spreading FUD. They *are* supported straight out of the
box. What isn't supported is their use in typedefs and that has a reason.
From gcc/c-decl.c :
/* This is an unnamed decl.
If we have something of the form "union { list } ;" then this
is the anonymous union extension. Similarly for struct.
If this is something of the form "struct foo;", then
If MS extensions are enabled, this is handled as an
anonymous struct.
Otherwise this is a forward declaration of a structure tag.
If this is something of the form "foo;" and foo is a TYPE_DECL, then
If MS extensions are enabled and foo names a structure, then
again this is an anonymous struct.
Otherwise this is an error.
Oh what a horrid tangled web we weave. I wonder if MS consciously
took this from Plan 9 or if it was an accident of implementation
that took root before someone noticed the bug... */
Do you see the ambiguities they introduce and why *this* requires
explicite activation by the user?
> That's why they are there and I would really like them to stay there
They don't have to be removed, only their use in typedefs would need to go.
> I still don't understand why you have a problem with the unnamed structs
> and unions considering your gcc should support them... Could you explain?
Wouldn't the above not be enough reason to refrain from using such
constructs?
Philipp
--
Philipp Thomas
SUSE LINUX AG, Maxfeldstr. 5, D-90409 Nuremberg, Germany
|