initialising anonymous unions

Jim Wilson wilson@specifixinc.com
Mon Oct 27 06:56:00 GMT 2003


David Howells wrote:
> 	dhowells>gcc -s union.c 
> 	union.c:15: unknown field `x' specified in initializer

I suggest submitting a bug report into the FSF gcc bugzilla database if 
you haven't already.

This looks like a case where the GCC extension for anonymous unions 
doesn't support the ISO C99 syntax for initializing structures.  This is 
a common problem with GCC extensions, they don't always interact well 
with other language features.  It looks like this probably should work, 
but it would be useful to check other compilers for precedent either way.

You can work around this problem by adding braces around the initializer 
for .x.  However, this is only useful if you have a fully bracketed 
in-order initializer, which defeats the purpose of using named initializers.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



More information about the Gcc mailing list