D - Anonymous union in a class ?
- Myles Strous (27/27) Sep 23 2002 Is it not possible to use an anonymous union in a class ?
- Walter (1/1) Sep 25 2002 Thanks. I'll check it out, it looks like a compiler bug. -Walter
Is it not possible to use an anonymous union in a class ? The following code gives me an error of : test.d: class IP 2duplicate union initialization for address I don't have a C/C++ background, so I'm probably doing something silly. Regards, Myles. ----- // test.d - a modified extract from Pavel's socket.d class IP { union { ubyte[4] b; uint address; } this(ubyte b1, ubyte b2, ubyte b3, ubyte b4) { b[0] = b1; b[1] = b2; b[2] = b3; b[3] = b4; printf("%d.%d.%d.%d", b[0], b[1], b[2], b[3]); printf("%d", address); } } int main() { IP ip; ip = new IP(23, 8, 42, 15); return 0; }
Sep 23 2002
Thanks. I'll check it out, it looks like a compiler bug. -Walter
Sep 25 2002