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

Julien Fischer jfischer at opturion.com
Mon Jan 12 17:02:10 AEDT 2015


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.

Cheers,
Julien.



More information about the reviews mailing list