Hi Eric, > --- a/lib/unistd.in.h > +++ b/lib/unistd.in.h > @@ -346,9 +346,6 @@ extern int ftruncate (int fd, off_t length); > > > #if @GNULIB_GETCWD@ > -/* Include the headers that might declare getcwd so that they will not > - cause confusion if included after this file. */ > -# include <stdlib.h> > # if @REPLACE_GETCWD@ > /* Get the name of the current working directory, and put it in SIZE bytes > of BUF.
While setting up a comment, stating why <stdlib.h> is included above, I found that on mingw, getcwd is declared in yet another header: in <io.h>. Applying this: 2009-12-23 Bruno Haible <[email protected]> unistd: Ensure getcwd gets declared before being overridden. * lib/unistd.in.h: Conditionally include <io.h>. --- lib/unistd.in.h.orig Wed Dec 23 10:55:43 2009 +++ lib/unistd.in.h Wed Dec 23 10:47:51 2009 @@ -39,8 +39,14 @@ /* mingw fails to declare _exit in <unistd.h>. */ /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */ +/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */ #include <stdlib.h> +/* mingw declares getcwd in <io.h>, not in <unistd.h>. */ +#if @GNULIB_GETCWD@ && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) +# include <io.h> +#endif + #if ((@GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@) \ || (@GNULIB_READLINK@ && (!...@have_readlink@ || @REPLACE_READLINK@)) \ || (@GNULIB_READLINKAT@ && !...@have_readlinkat@))
