Union literals? (D1.0)

Leandro Lucarella llucax at gmail.com
Thu Feb 7 13:24:39 PST 2008


Is there union literals?

I have this (example):

struct A
{
	int x;
}

struct B
{
	char z;
}

struct C
{
	int y;
	union U
	{
		A a;
		static struct D
		{
			B b;
			uint domain;
		}
		D d;
	}
	U u;
}

Is there any way to initialize a C in one line (so it can be const)? Like:

const c = C(10, C.U.D(B('b'), 15));

But I get: Error: cannot implicitly convert expression (D((B('b')),15u))
           of type D to A.

Unions can only be initalized to its first member?



-- 
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Salvajes, de traje, me quieren enseņar
Salvajes, de traje, me quieren educar


More information about the Digitalmars-d-learn mailing list