bug-gnulib
[Top][All Lists]
Advanced

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

Re: #defines in unistd.h


From: Bruno Haible
Subject: Re: #defines in unistd.h
Date: Mon, 5 Apr 2010 17:34:46 +0100
User-agent: KMail/1.9.9

> 2010-03-28  Bruno Haible  <address@hidden>
> 
>       unistd: Avoid #define replacements in C++ mode.
>       * lib/unistd.in.h (socket, connect, accept, bind, getpeername,
>       getsockname, getsockopt, listen, recv, send, recvfrom, sendto,
>       setsockopt, shutdown, select): In C++, attach a warning to the function
>       if possible, rather than #defining the symbol to a dysfunctional alias.
>       Reported by John W. Eaton <address@hidden>.

Something similar needs also be applied to our sys/socket.h replacement,
because I'm seeing this error on mingw:

  depbase=`echo test-sys_select-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
        g++-3 -mno-cygwin -DHAVE_CONFIG_H -I.  -I. -I. -I.. -I./.. -I../gllib 
-I./../gllib -I/usr/local/mingw/include -Wall   -MT test-sys_select-c++.o -MD 
-MP -MF $depbase.Tpo -c -o test-sys_select-c++.o test-sys_select-c++.cc &&\
          mv -f $depbase.Tpo $depbase.Po
  In file included from test-sys_select-c++.cc:22:
  ../gllib/sys/select.h:370: error: 
`select_used_without_including_sys_select_h' was not declared in this scope
  make[4]: *** [test-sys_select-c++.o] Error 1


2010-04-05  Bruno Haible  <address@hidden>

        sys_socket: Avoid #define replacements in C++ mode.
        * lib/sys_socket.in.h (close, gethostname, select): In C++, attach a
        warning to the function if possible, rather than #defining the symbol
        to a dysfunctional alias.

--- lib/sys_socket.in.h.orig    Mon Apr  5 18:32:50 2010
+++ lib/sys_socket.in.h Mon Apr  5 18:28:16 2010
@@ -183,13 +183,23 @@
 /* Wrap everything else to use libc file descriptors for sockets.  */
 
 #if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
-# undef close
-# define close close_used_without_including_unistd_h
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#  undef close
+#  define close close_used_without_including_unistd_h
+# else
+   _GL_WARN_ON_USE (close,
+                    "close() used without including <unistd.h>");
+# endif
 #endif
 
 #if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
-# undef gethostname
-# define gethostname gethostname_used_without_including_unistd_h
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#  undef gethostname
+#  define gethostname gethostname_used_without_including_unistd_h
+# else
+   _GL_WARN_ON_USE (gethostname,
+                    "gethostname() used without including <unistd.h>");
+# endif
 #endif
 
 #if @GNULIB_SOCKET@
@@ -571,8 +581,13 @@
 #endif
 
 #if @HAVE_WINSOCK2_H@
-# undef select
-# define select                select_used_without_including_sys_select_h
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#  undef select
+#  define select select_used_without_including_sys_select_h
+# else
+   _GL_WARN_ON_USE (select,
+                    "select() used without including <sys/select.h>");
+# endif
 #endif
 
 #if @GNULIB_ACCEPT4@




reply via email to

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