Unnamed unions and C99 named initializers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,


let's begin with some code, point in case here, a struct with an unnamed 
union:

	struct foo {
		int a;
		union {
			int x;
		};
	};

Given this struct, it is possible to access the x by using ".x" on the 
struct:

	struct foo test;
	test.x = 7; /* works */

So essentially it behaves as if the union was not there. So far so good.
But if one can use .x on the struct in this way, why is not it possible 
to do the same in a C99 named initializer list?

	struct foo test = {.x = 7}; /* fails */

Seems kinda counter-intuitive. Did I spot a bug^W missing feature in the 
C99 standard?

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux