The current gnulib unistd.in.h file includes the following section: #if @GNULIB_GETHOSTNAME@ /* Get all possible declarations of gethostname(). */ # if @UNISTD_H_HAVE_WINSOCK2_H@ # if !defined _GL_SYS_SOCKET_H # undef socket # define socket socket_used_without_including_sys_socket_h # undef connect # define connect connect_used_without_including_sys_socket_h # undef accept # define accept accept_used_without_including_sys_socket_h # undef bind # define bind bind_used_without_including_sys_socket_h # undef getpeername # define getpeername getpeername_used_without_including_sys_socket_h # undef getsockname # define getsockname getsockname_used_without_including_sys_socket_h # undef getsockopt # define getsockopt getsockopt_used_without_including_sys_socket_h # undef listen # define listen listen_used_without_including_sys_socket_h # undef recv # define recv recv_used_without_including_sys_socket_h # undef send # define send send_used_without_including_sys_socket_h # undef recvfrom # define recvfrom recvfrom_used_without_including_sys_socket_h # undef sendto # define sendto sendto_used_without_including_sys_socket_h # undef setsockopt # define setsockopt setsockopt_used_without_including_sys_socket_h # undef shutdown # define shutdown shutdown_used_without_including_sys_socket_h # endif # if !defined _GL_SYS_SELECT_H # undef select # define select select_used_without_including_sys_select_h # endif # endif #endif
I think these definitions can cause trouble for C++ programs that do things like foo.h: ----- class foo { public: foo (void) { } void accept (void); }; foo.cc: ------ #include <unistd.h> #include "foo.h" void foo::accept (void) { } // Oops, accept is not a member of class foo. or C programs like this: foo.h: ----- extern int accept; extern void doit (void); foo.c: ----- #include <unistd.h> #include "foo.h" int accept = 0; void doit (void) { accept = 1; } main.c: ------ #include "foo.h" int main (void) { accept = -1; doit (); return accept; } /* oops, what happened to the global variable accept? */ jwe