initialising anonymous unions

David Howells dhowells@redhat.com
Fri Oct 17 11:57:00 GMT 2003


Should the following compile?

	struct wibble {
		int	a;
		int	b;
		int	c;
		union {
			int	x;
			void	*y;
		};
	};

	struct wibble fred = {
		.a	= 1,
		.b	= 2,
		.c	= 3,
		.x	= 1234,
	};

Or is there some other way to refer to x or y?

What I see is:

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

David



More information about the Gcc mailing list