[Live-devel] A question about defining _MSWSOCK_ in netcommon.h

Jeff Shanab jshanab at jfs-tech.com
Mon Dec 31 10:39:31 PST 2018


in netcommon.h we have the following code :
...
1> /* Windows */
2> #if defined(WINNT) || defined(_WINNT) || defined(__BORLANDC__) ||
defined(__MINGW32__) || defined(_WIN32_WCE) || defined (_MSC_VER)
3> #define _MSWSOCK_
4> #include <winsock2.h>
5> #include <ws2tcpip.h>
6> #endif
7> #include <windows.h>

...
>From my understanding and this ref. http://sockets.com/mswsock.htm, #12,
It looks like the define on line 3 was placed there to allow it's include
before windows.h which would include winsock2.h by itself and is included
anyway on 7. (No excuse for MS's thiasco here)

When I tried using live555 with another lib that needs one of the functions
in mswsock that is not routed to WS2_32.dll, that define disables all of
mswsock.h socket extensions and makes it a NOP.

Both libs build fine and work on their own just fine, but an application
using both libs must use both includes. It took a couple of days to find
how line 3 serves as a poison pill to the other lib. Visual Studio's
ability to show the state of the enabled code is poor and can be
missleading.

I removed line 3 and rebuilt live555 without issue but that is just one
console app.

Is there a "best practice" way to handle this? Something all library
writers can agree on? (Other than just switching to Linux, I must build on
the big 3 :-) )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20181231/3d32c33f/attachment.html>


More information about the live-devel mailing list