bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

winsock wrapper tweaks


From: Bruno Haible
Subject: winsock wrapper tweaks
Date: Mon, 29 Sep 2008 01:49:39 +0200
User-agent: KMail/1.5.4

Hi Paolo,

In gettext, when building on mingw, I compile gnulib in C mode but use some
of it in C++ mode. I got link errors because of rpl_select and rpl_close.
Adding the usual 'extern "C" { ... }' in the header file fixed it. OK?

Also, I compile with -Wall, and got two warnings about unused variables. OK
to remove them?

Proposed patch:


2008-09-28  Bruno Haible  <address@hidden>

        * lib/sys_socket.in.h: Wrap the definitions in 'extern "C"'.
        * lib/sys_select.in.h: Likewise.

        * lib/winsock.c (rpl_close, rpl_socket): Remove unused variables.

*** lib/sys_select.in.h.orig    2008-09-29 01:43:16.000000000 +0200
--- lib/sys_select.in.h 2008-09-29 01:38:58.000000000 +0200
***************
*** 40,49 ****
  # include <sys/socket.h>
  
  # if @HAVE_WINSOCK2_H@
  #  undef select
  #  define select              rpl_select
- 
  extern int rpl_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
  # endif
  
  #endif
--- 40,58 ----
  # include <sys/socket.h>
  
  # if @HAVE_WINSOCK2_H@
+ 
+ #  ifdef __cplusplus
+ extern "C" {
+ #  endif
+ 
  #  undef select
  #  define select              rpl_select
  extern int rpl_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
+ 
+ #  ifdef __cplusplus
+ }
+ #  endif
+ 
  # endif
  
  #endif
*** lib/sys_socket.in.h.orig    2008-09-29 01:43:16.000000000 +0200
--- lib/sys_socket.in.h 2008-09-29 01:38:58.000000000 +0200
***************
*** 105,110 ****
--- 105,114 ----
  
  typedef int socklen_t;
  
+ #  ifdef __cplusplus
+ extern "C" {
+ #  endif
+ 
  /* Re-define FD_ISSET to avoid a WSA call while we are not using 
     network sockets.  */
  static inline int
***************
*** 175,180 ****
--- 179,188 ----
  extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
  extern int rpl_setsockopt (int, int, int, const void *, int);
  
+ #  ifdef __cplusplus
+ }
+ #  endif
+ 
  # endif /* HAVE_WINSOCK2_H */
  
  #endif /* HAVE_SYS_SOCKET_H */
*** lib/winsock.c.orig  2008-09-29 01:43:16.000000000 +0200
--- lib/winsock.c       2008-09-29 01:28:05.000000000 +0200
***************
*** 51,57 ****
  rpl_close (int fd)
  {
    char buf[sizeof (int)];
-   int bufsize = sizeof (buf);
    SOCKET sock = FD_TO_SOCKET (fd);
    WSANETWORKEVENTS ev;
  
--- 51,56 ----
***************
*** 107,114 ****
  int
  rpl_socket (int domain, int type, int protocol)
  {
-   int fd;
- 
    /* We have to use WSASocket() to create non-overlapped IO sockets.
       Overlapped IO sockets cannot be used with read/write.  */
    SOCKET fh = WSASocket (domain, type, protocol, NULL, 0, 0);
--- 106,111 ----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]