> * Eric Blake <roy...@erqung.pbz> [2011-07-14 07:43:40 -0600]: > > On 07/14/2011 07:37 AM, Sam Steingold wrote: >> Hi, >> in what order do I include sys/socket and unistd? >> sys_socket.in.h: >> #if @HAVE_WINSOCK2_H@ && !defined _GL_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 >> >> so, on windows, I must include unistd before sys/socket, otherwise close >> will not work. >> >> otoh: >> unistd.in.h: >> #if @GNULIB_GETHOSTNAME@ >> /* Get all possible declarations of gethostname(). */ >> # if @UNISTD_H_HAVE_WINSOCK2_H@ >> # if !defined _GL_SYS_SOCKET_H >> # if !(defined __cplusplus && defined GNULIB_NAMESPACE) >> # undef socket >> # define socket socket_used_without_including_sys_socket_h >> >> so I must include sys/socket before unistd, otherwise socket (and many >> others) will not work. >> >> so, what is the right order? > > Do you have an actual compilation error, or are you just trying to > understand the code?
this is an actual error, please see http://article.gmane.org/gmane.lisp.clisp.devel:22588 and the whole thread. > Both orders should work, if you are using the > gnulib modules for both headers. I have both modules. unistd is requested explicitly. sys_socket comes from a dependency. > Note that in unistd.in.h, on mingw, <sys/socket.h> is included prior to > this snippet of @GNULIB_GETHOSTNAME@, such that _GL_SYS_SOCKET_H is > defined and you never get the > socket_used_without_including_sys_socket_h, if you were using both > gnulib modules. the first mention of <sys/socket.h> in unistd.in.h is line 155: "socket() used without including <sys/socket.h>"); -- Sam Steingold (http://sds.podval.org/) on CentOS release 5.6 (Final) X 11.0.60900031 http://camera.org http://mideasttruth.com http://www.memritv.org http://dhimmi.com http://palestinefacts.org http://iris.org.il Single tasking: Just Say No.