From 4e86671af61ca43f17725aa4b79a555276432fed Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 21 Dec 2009 11:14:18 -0700 Subject: [PATCH] getsubopt: work around cygwin bug 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 --- ChangeLog | 6 ++++++ doc/posix-functions/getsubopt.texi | 4 ++++ lib/stdlib.in.h | 9 ++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0db0105933..434b7b3062 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-12-22 Eric Blake + 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. diff --git a/doc/posix-functions/getsubopt.texi b/doc/posix-functions/getsubopt.texi index 9ab69ee938..a5ce0fd703 100644 --- a/doc/posix-functions/getsubopt.texi +++ b/doc/posix-functions/getsubopt.texi @@ -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 diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index af9c35ea87..d46f5c9ede 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -66,6 +66,12 @@ struct random_data }; #endif +#if @GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK +/* On MacOS X 10.3, only declares mkstemp. */ +/* On Cygwin 1.7.1, only declares getsubopt. */ +# include +#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 declares mkstemp. */ -# include # endif #elif defined GNULIB_POSIXCHECK # undef mkstemp -- 2.30.2