bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stdlib tweak


From: Bruno Haible
Subject: Re: stdlib tweak
Date: Wed, 23 Dec 2009 10:59:07 +0100
User-agent: KMail/1.9.9

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  <address@hidden>

        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@ && (address@hidden@ || @REPLACE_READLINK@)) \
      || (@GNULIB_READLINKAT@ && address@hidden@))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]