This is the mail archive of the gcc@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]

Re: Unnamed unions


In the newer builds of gcc it is supported, that least in the 3.0 branch.
I tested on a cvs updated source (around 5am EST today).  It worked, might be 
a trouble with Apple's compiler
Thanks,
Andrew Pinski

> 
> 
>    Maybe this is the issue...
> 
>    I'm building with the C compiler, not the C++ compiler (since all the 
> files are .c files and since I need to access ObjC anyway).
> 
>    If I build with the C++ compiler, it does work, but if I do:
> 
> cc -Wall -O2 -ansi -pedantic /tmp/foo.c -o /tmp/foo
> 
> I get:
> 
> /tmp/foo.c:12: warning: ANSI C forbids member declarations with no 
> members
> /tmp/foo.c:12: warning: unnamed struct/union that defines no instances
> /tmp/foo.c: In function `main':
> /tmp/foo.c:20: structure has no member named `a'
> 
>    So, I guess I'll just replace these by hand.
> 
>    Thanks!
> 
> 
> On Friday, February 16, 2001, at 04:15  PM, James Dennett wrote:
> 
> > "Timothy J. Wood" wrote:
> >>
> >>    I end up porting a lot of code that is built with VC++ and/or
> >> Metrowerks to Mac OS X using gcc.  Apparently both of these compilers
> >> support the following:
> >>
> >> struct {
> >>    union {
> >>         int a, b;
> >>   };
> >> } x;
> >>
> >> int main()
> >> {
> >>      x.a = 1;
> >>      return 0;
> >> }
> >>
> >
> > I believe that this is Standard C++ (IIRC) and my g++ compiles it
> > happily when I type g++ -ansi -pedantic -o union union.C
> >
> > Note that I'm using a pretty up-to-date g++ snapshot.
> >
> > Hope this helps.
> >
> >
> > -- James Dennett.
> >
> 
> 


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