[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
stdlib tweak
From: |
Eric Blake |
Subject: |
stdlib tweak |
Date: |
Mon, 21 Dec 2009 18:24:10 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
I got this failure on cygwin, when building m4 with -DGNULIB_POSIXCHECK (m4
does not use the getsubopt module):
gcc -std=gnu99 -I. -I../../lib -I/cygdrive/c/cygwin/usr/local/include -
DGNULIB_POSIXCHECK=1 -MT gl_avltree_oset.o -MD -MP -
MF .deps/gl_avltree_oset.Tpo -c -o gl_avltree_oset.o ../../lib/gl_avltree_oset.c
In file included from /usr/include/unistd.h:4,
from ./unistd.h:27,
from ./stdlib.h:310,
from ../../lib/gl_avltree_oset.c:23:
/usr/include/sys/unistd.h:172: error: parse error before "void"
That line in the system header is:
int getsubopt(char **, char * const *, char **);
It turns out that our replacement stdlib.h was including <unistd.h> after it
had already defined getsubopt into a macro, so the macro then interfered with
the cygwin header's attempts to declare getsubopt. Yet another reason why my
proposed warn-on-use idiom will be nicer (no macro collisions with system
declarations), although that is running into some implementation snags
(AC_CHECK_DECLS_ONCE only works for the default headers of AC_INCLUDES_DEFAULT,
but I want to minimize decl checks for other headers such as math.h).
From: Eric Blake <address@hidden>
Date: Mon, 21 Dec 2009 11:14:18 -0700
Subject: [PATCH] stdlib: ensure system headers are complete before overriding
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.
Signed-off-by: Eric Blake <address@hidden>
---
ChangeLog | 6 ++++++
lib/stdlib.in.h | 8 +++++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c2ae54c..4128c26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-12-21 Eric Blake <address@hidden>
+
+ stdlib: ensure system headers are complete before overriding
+ * lib/stdlib.in.h (includes): Move unistd inclusion sooner, to
+ avoid conflicting with system getsubopt.
+
2009-12-21 Eric Blake <address@hidden>
warn-on-use: use instead of link-warning
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index af9c35e..39782d2 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -66,6 +66,11 @@ struct random_data
};
#endif
+#if @GNULIB_MKSTEMP@
+/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
+# include <unistd.h>
+#endif
+
/* The definition of GL_LINK_WARNING is copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -266,9 +271,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
--
1.6.4.2
- stdlib tweak,
Eric Blake <=
- Re: stdlib tweak, Eric Blake, 2009/12/21
- Re: stdlib tweak, Eric Blake, 2009/12/21
- Re: stdlib tweak, Jim Meyering, 2009/12/22
- Re: stdlib tweak, Eric Blake, 2009/12/22
- Re: stdlib tweak, Jim Meyering, 2009/12/22
- Re: stdlib tweak, Eric Blake, 2009/12/22
- Re: stdlib tweak, Jim Meyering, 2009/12/23
- Re: stdlib tweak, Bruno Haible, 2009/12/23
- Re: stdlib tweak, Eric Blake, 2009/12/23