Re: PATCH: Windows sockets

Christopher Faylor
2005-03-26T17:48:25Z

On Sat, Mar 26, 2005 at 09:38:15AM -0800, Mark Mitchell wrote:
>Thanks for the quick review.
>
>> Here is a sumary of the changes in this patch:
>>
>> 1. Link with -lws2_32 on MinGW so we can use sockets.
>>
>>Can't you just use a standard autoconf check to check for that library
>>instead of hardcoding it to be linked in on MinGW?
>
>I could do that -- but I didn't because there are Windows configurations
>that do not want to use Winsock. For example, we don't want to link in
>this library on Cygwin; we just want to let the Cygwin DLL take care of
>things.
>
>> 2. In defs.h, define WINAPI so that source files know whether they are
>> supposed to use the Windows API.
>>
>>This is bad. Yet another #ifdef WINDHOOS when we really are trying to
>>get rid of those.
>
>This is the same problem as above; I could autoconf things for Windows,
>but those autoconf tests would fire under Cygwin as well.

I guess you could only check for the existence of ws2_32 when the host
is mingw, but that seems sort of redundant given that there is a
preprocessor test which precisely tells what needs to be done. While
I'm normally a big fan of using conditionals like "HAVE_WINSOCK", it
doesn't seem like it makes the code any clearer to use these types of
conditionals in this case unless we really anticipate that there will
be another OS out there with some of the pecularities os Windows but
not all of them.

One observation is that maybe you could do something like:

#if defined (__WIN32__) && !defined (__CYGWIN__)
# define MINGW
#endif

and use #ifdef MINGW where appropriate.

cgf