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 0db010593347e7a927f6334e1bb90f902806b029..434b7b30620cc28b06395e17d30a5d3535b6e347 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 9ab69ee938225509991ff7b5adb0d76b2981b500..a5ce0fd70364b4d7307dadd72b559afe9611e381 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 af9c35ea8775e7e7d0b323c7be84c0b7e9e4a414..d46f5c9ede4ba55994f2abb8e7587ad0fd1f2b7f 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