September 24, 2002 Anonymous union in a class ? | ||||
---|---|---|---|---|
| ||||
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; } |
September 26, 2002 Re: Anonymous union in a class ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Myles Strous | Thanks. I'll check it out, it looks like a compiler bug. -Walter |
Copyright © 1999-2021 by the D Language Foundation