This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

anonymous structs in unions


I've found out quite a while ago that gcc and g++ don't like constructs like:

union something{
   struct{
     int a, int b;
   };
   struct{
     float c, d;
   };
} a;

a.c = 12.f;

So far, the only place where I've gotten problems because of this was code 
that defined matrices as unions of a float array and a float struct, and that 
was quickly fixed by some #defines. Anyway, right now I have to port some 
visualc code to g++/linux and I stumbled across this problem in other areas 
which are harder to modify (mainly because the rest of the team members 
opposing to changing half their code :) and secondly because some hairy bit 
unions come into play).

My theoretical question is if this feature was not included in gcc/g++ because 
it does not comply with ANSI or for other reasons. My practical question is 
if anything can be done besides convincing my team mates to rewrite code or 
hacking gcc.

Thanks.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]