getsubopt: work around cygwin bug
authorEric Blake <ebb9@byu.net>
Mon, 21 Dec 2009 18:14:18 +0000 (11:14 -0700)
committerEric Blake <ebb9@byu.net>
Tue, 22 Dec 2009 13:53:45 +0000 (06:53 -0700)
On cygwin, compiling with -DGNULIB_POSIXCHECK failed because
the getsubopt link warning definition interfered with the
inclusion of the system header.  The fix, as always in these
types of problems, is to ensure that system headers are
completely included before doing any overrides.

* lib/stdlib.in.h (includes): Move unistd inclusion sooner, to
avoid conflicting with system getsubopt.
* doc/posix-functions/getsubopt.texi (getsubopt): Document the
bug.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/posix-functions/getsubopt.texi
lib/stdlib.in.h

index 0db0105..434b7b3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-12-22  Eric Blake  <ebb9@byu.net>
 
+       getsubopt: work around cygwin bug
+       * lib/stdlib.in.h (includes): Move unistd inclusion sooner, to
+       avoid conflicting with system getsubopt.
+       * doc/posix-functions/getsubopt.texi (getsubopt): Document the
+       bug.
+
        getopt: synchronize from glibc
        * lib/getopt.c (_getopt_initialize, _getopt_internal_r): Swap
        parameter order.  Adjust all callers.
index 9ab69ee..a5ce0fd 100644 (file)
@@ -9,6 +9,10 @@ Gnulib module: getsubopt
 Portability problems fixed by Gnulib:
 @itemize
 @item
+This function is declared in @code{unistd.h} instead of
+@code{stdlib.h} on some platforms:
+Cygwin 1.7.1.
+@item
 This function is missing on some platforms:
 mingw, BeOS.
 @end itemize
index af9c35e..d46f5c9 100644 (file)
@@ -66,6 +66,12 @@ struct random_data
 };
 #endif
 
+#if @GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK
+/* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
+/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt.  */
+# include <unistd.h>
+#endif
+
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
@@ -266,9 +272,6 @@ extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/)
    set.  */
 #  define mkstemp rpl_mkstemp
 extern int mkstemp (char * /*template*/) _GL_ARG_NONNULL ((1));
-# else
-/* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
-#  include <unistd.h>
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef mkstemp