Why is a cast needed here?
Daniel Giddings
daniel.giddings at gmail.com
Sun Nov 26 02:25:33 PST 2006
Looks like its a bug in 0.175, I've just needed to add the same casts to my
code. It's a compiler issue rather than a lib issue, as the SocketType and
ProtocolType are declared as enums in the same way, but don't need the cast.
:-) Dan
"Dave" <Dave_member at pathlink.com> wrote in message
news:eka11i$15v4$1 at digitaldaemon.com...
> import std.socket;
>
> void main()
> {
> //Socket s = new
> Socket(AddressFamily.INET,SocketType.STREAM,ProtocolType.TCP);
> Socket s = new
> Socket(cast(AddressFamily)AddressFamily.INET,SocketType.STREAM,ProtocolType.TCP);
> }
>
> Why is the 'cast(AddressFamily)' needed?
>
> W/o the cast:
>
> t.d(5): constructor std.socket.Socket.this () does not match parameter
> types (int,SocketType,ProtocolType)
> t.d(5): Error: cannot implicitly convert expression (2) of type int to
> AddressFamily
> t.d(5): Error: cannot implicitly convert expression (6) of type
> ProtocolType to char[]
> t.d(5): Error: cannot cast int to char[]
>
> Thanks!
More information about the Digitalmars-d-learn
mailing list