Michael Stefaniuc wrote:
i'm not sure if the compiler will optimize away the assert from __handle2socket on machines where sizeof(HANDLE) = sizeof(SOCKET).
gcc does optimize this away if the function is declared inline, checked that. The assert is used only when new sockets are allocated (i.e. only in socket() and accept() calls), it is certainly not performance-critical.
Alexandre Julliard wrote:
The assert is useless anyway. Even if the types have different sizes you'll need to allocate a billion handles to trigger it.
If _you_ say that - I didn't feel bold enough to argue that way :-)
It's much better to use a simple cast (without ULONG_PTR) so the compiler will warn if the pointer and integer are different sizes.
If you really want a compiler warning rather than a runtime error, OK.
Perhaps someone could check if SOCKET is really a 32bit type on 64bit Windows.
Martin