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? Both orders should work, if you are using the gnulib modules for both headers. 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. -- Eric Blake ebl...@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature