* anonymous structs in unions
@ 2003-02-27 12:38 Mihnea Balta
2003-02-27 17:06 ` Dan Kegel
0 siblings, 1 reply; 3+ messages in thread
From: Mihnea Balta @ 2003-02-27 12:38 UTC (permalink / raw)
To: gcc-help
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: anonymous structs in unions
2003-02-27 12:38 anonymous structs in unions Mihnea Balta
@ 2003-02-27 17:06 ` Dan Kegel
2003-02-28 7:57 ` Mihnea Balta
0 siblings, 1 reply; 3+ messages in thread
From: Dan Kegel @ 2003-02-27 17:06 UTC (permalink / raw)
To: Mihnea Balta; +Cc: gcc-help
Mihnea Balta wrote:
> 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;
If you fix the typos (, -> ;), that compiles nicely with gcc3.2.
- Dan
--
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: anonymous structs in unions
2003-02-27 17:06 ` Dan Kegel
@ 2003-02-28 7:57 ` Mihnea Balta
0 siblings, 0 replies; 3+ messages in thread
From: Mihnea Balta @ 2003-02-28 7:57 UTC (permalink / raw)
To: Dan Kegel; +Cc: gcc-help
Hmm, I tried with 2.95.3 and it complained. I take it gcc 3.2 understands this
kind of constructs, I might consider switching to it (and recompiling tons of
software that uses the old ABI, but that's it, it had to happen someday :) )
Thank you for clearing this up for me.
On Thursday 27 February 2003 19:15, Dan Kegel wrote:
> Mihnea Balta wrote:
> > 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;
>
> If you fix the typos (, -> ;), that compiles nicely with gcc3.2.
> - Dan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-02-28 7:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-27 12:38 anonymous structs in unions Mihnea Balta
2003-02-27 17:06 ` Dan Kegel
2003-02-28 7:57 ` Mihnea Balta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).