[m-rev.] [PATCH 2/2] [net] Make the C code compatible with Windows

Paul Bone paul at bone.id.au
Tue Jan 13 12:34:36 AEDT 2015


On Mon, Jan 12, 2015 at 05:02:10PM +1100, Julien Fischer wrote:
>
> Hi Paul,
>
> On Sat, 10 Jan 2015, Paul Bone wrote:
>
>> extras/net/netdb.m:
>> extras/net/sockets.m:
>> extras/net/tcp.m:
>> extras/net/types.m:
>>    Include the correct header files.
>>
>>    Fix the order of statements in a code block.
>>
>>    Workarround the missing SHUT_RDWR macro on windows.
>>
>>    Avoid use of socklen_t.
>> ---
>> extras/net/netdb.m   | 10 ++++++++--
>> extras/net/sockets.m |  7 ++++---
>> extras/net/tcp.m     |  4 ++--
>> extras/net/types.m   | 13 +++++++++----
>> 4 files changed, 23 insertions(+), 11 deletions(-)
>>
>> diff --git a/extras/net/netdb.m b/extras/net/netdb.m
>> index 8021d7e..fe5ab15 100644
>> --- a/extras/net/netdb.m
>> +++ b/extras/net/netdb.m
>> @@ -82,7 +82,12 @@
>>
>> :- pragma foreign_decl("C",
>> "
>> -#include <netdb.h>
>> +#ifdef MR_WIN32
>> +    #include <winsock2.h>
>> +    #include <ws2tcpip.h>
>
> You need to do:
>
>    #include ""mercury_windows.h""
>
> *before* you include winsock2.h etc there.  Doing so ensures that the
> macros that prevent the automatic inclusion of winsock.h (which will
> conflict with winsock2.h) are defined.  (See comments in
> runtime/mercury_windows.h.)
>
> And indeed everywhere else stuff from the Windows API is #included.
>

Thanks Julien.

I just started getting errors because of this when compiling an application
against this library (but not the library itself).  I've fixed it in my
workspace but I'm still getting the errors.  Once I sort that out I'll
commit my changes.

Thanks for the heads-up.


-- 
Paul Bone



More information about the reviews mailing list