On Wed, 2004-03-03 at 12:22, Philipp Thomas wrote:
> * 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.
I apologise if what I said wasn't correct. Thank you for correcting me.
> 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.
We could do that. But I still don't see why we have to... We supply
-fms-extensions, so why doesn't it work for some people? It seems to me
every gcc version does something different with respect to anonymous
structures/unions... gcc-2.96 worked as is, later gcc 3.something
didn't work at all, then a later one worked with -fms-extensions. But
people using various architecture ports of gcc still complain it doesn't
work. Ugh...
Would all our problems go away if we were to remove the use of anonymous
structs and unions in typedefs (i.e. just removed the typedefs and used
struct blah instead of blah) everywhere?
Would it then work with all versions of gcc? (including 2.95?) If not
which versions would it work with? To make such a big move there would
have to be a pretty good reason as it would mean making the next libntfs
release no longer compatible with the previous one on both a binary and
source code level...
> > 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?
No. (-: It works on MS Windows/Visual C++ so why shouldn't it work on
Linux? It is very annoying not to be able to just copy some MS header
files because of this issue...
Best regards,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ &
http://www-stu.christs.cam.ac.uk/~aia21/
|