problem with nameless structs and unions

Tuukka Lehtonen tvlehton@cc.hut.fi
Fri Mar 16 05:49:00 GMT 2001


Hi,

I'm already sorry, if this is the wrong place to send this question but
anyway, here I go:

take this simple structure for example

struct vec {
  union {
    int v[3];
    struct {
      int x,y,z;
    };
  };
};

GCC doesn't seem to support nameless structures inside unions for
example..

It just reports this when compiling the above code:
...anonymous class type not used to declare any objects

This would be very useful in many situations.
Is there any way to go round this flaw, to achieve the same functionality
as the above structure should provide, that is accessing the same elements
eith either indexing them or using plain vector component names?

-Tuukka Lehtonen



More information about the Gcc-help mailing list