2010/3/20 Eric Blake <ebl...@redhat.com>: > Since commit 4e86671a, gethostname failed to compile on mingw. > Gnulib's sys/socket.h includes winsock2.h, which then includes > unistd.h prior to declaring gethostname. Therefore, unistd.h > cannot replace gethostname until winsock2.h is complete. > > * lib/sys_socket.in.h (includes): Set witness when including > winsock2.h. > * lib/unistd.in.h (includes): Don't replace anything when included > by winsock2.h. > Reported by Matthias Bolte. > > Signed-off-by: Eric Blake <ebl...@redhat.com> > --- > > Thanks to Matthias for doing the git bisect to narrow down > the cause of his error: > > # i686-pc-mingw32-gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT sockets.o > -MD -MP -MF -deps/sockets.Tpo -c -o sockets.o sockets.c > In file included from ./sys/socket.h:389, > from sockets.h:37, > from sockets.c:23: > /usr/i686-pc-mingw32/sys-root/mingw/include/winsock2.h:635: error: > conflicting types for 'rpl_gethostname' > ./unistd.h:824: note: previous declaration of 'rpl_gethostname' was here > > I believe this will solve the issue, but would appreciate some testing > by Matthias. I also think that this is the same issue as: > http://lists.gnu.org/archive/html/bug-gnulib/2010-01/msg00183.html >
I tested this patch and can confirm that this patch fixes the gethostname compile issue on MinGW. Thanks. Matthias