This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Unnamed unions
- To: James Dennett <jdennett at acm dot org>
- Subject: Re: Unnamed unions
- From: "Timothy J. Wood" <tjw at omnigroup dot com>
- Date: Fri, 16 Feb 2001 16:21:58 -0800
- Cc: Doug Landauer <landauer at apple dot com>, gcc at gcc dot gnu dot org
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.
>