enet icon indicating copy to clipboard operation
enet copied to clipboard

don't include winsock2.h in public headers

Open ligfx opened this issue 8 years ago • 4 comments

Windows headers have a tendency to pollute the global namespace and can cause issues with code that's not expecting it. enet should be a friendly neighbor and not expose Windows headers to end-users :)

ligfx avatar Jan 24 '17 21:01 ligfx

@lsalzman Any thoughts on this?

ligfx avatar Nov 02 '17 21:11 ligfx

This won't work because the ENET_SOCKETSET_* and the ENET_HOST_TO_NET/ENET_NET_TO_HOST macros require winsock, and may be used as part of ENet's API.

lsalzman avatar Nov 03 '17 01:11 lsalzman

Dang, I didn't see those. Would you be open to another solution like, forward-declaring the SOCKET/ENetSocket type in the types.h header?

My use-case is I want to keep Windows headers out of my code headers (so they don't propagate), but still be able to use ENet directly in member variables or for function arguments.

ligfx avatar Nov 04 '17 14:11 ligfx

I'll work something out with a define you can use before including to stop winsock.

lsalzman avatar Nov 04 '17 14:11 lsalzman