bug-gnulib
[Top][All Lists]
Advanced

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

Re: stdlib tweak


From: Eric Blake
Subject: Re: stdlib tweak
Date: Mon, 21 Dec 2009 18:43:54 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Eric Blake <ebb9 <at> byu.net> writes:

> 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.

I did a quick check to see if any other headers suffered from this problem, 
based on a rather simple heuristic of an instance of #include after line 99:

$ git grep -n 'include <' lib/*.in.h | grep ':[0-9][0-9][0-9]'

Most of the hits were false positives (in comments, the header being included 
that late is not overridden by gnulib, or the file really had 100 lines prior 
to the first overridden function declaration).  But it did point out the 
following cleanups:


From: Eric Blake <address@hidden>
Date: Mon, 21 Dec 2009 11:32:58 -0700
Subject: [PATCH] math, unistd: avoid redundant includes

* lib/math.in.h (isnan): No need to re-include <math.h>.
* lib/unistd.in.h (getcwd): Likewise, for <stdlib.h>.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog       |    4 ++++
 lib/math.in.h   |    3 ---
 lib/unistd.in.h |    3 ---
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4128c26..763405a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2009-12-21  Eric Blake  <address@hidden>

+       math, unistd: avoid redundant includes
+       * lib/math.in.h (isnan): No need to re-include <math.h>.
+       * lib/unistd.in.h (getcwd): Likewise, for <stdlib.h>.
+
        stdlib: ensure system headers are complete before overriding
        * lib/stdlib.in.h (includes): Move unistd inclusion sooner, to
        avoid conflicting with system getsubopt.
diff --git a/lib/math.in.h b/lib/math.in.h
index 27c9b25..6aeaec2 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -411,7 +411,6 @@ extern int gl_isinfl (long double x);
 # if @HAVE_ISNANF@
 /* The original <math.h> included above provides a declaration of isnan macro
    or (older) isnanf function.  */
-#  include <math.h>
 #  if __GNUC__ >= 4
     /* GCC 4.0 and newer provides three built-ins for isnan.  */
 #   undef isnanf
@@ -434,7 +433,6 @@ extern int isnanf (float x);
    to 'double' numbers earlier but now is a type-generic macro.  */
 # if @HAVE_ISNAND@
 /* The original <math.h> included above provides a declaration of isnan 
macro.  */
-#  include <math.h>
 #  if __GNUC__ >= 4
     /* GCC 4.0 and newer provides three built-ins for isnan.  */
 #   undef isnand
@@ -455,7 +453,6 @@ extern int isnand (double x);
 /* Test for NaN for 'long double' numbers.  */
 # if @HAVE_ISNANL@
 /* The original <math.h> included above provides a declaration of isnan macro 
or (older) isnanl function.  */
-#  include <math.h>
 #  if __GNUC__ >= 4
     /* GCC 4.0 and newer provides three built-ins for isnan.  */
 #   undef isnanl
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 0cf9a87..f37c7ba 100644
--- 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.
-- 
1.6.4.2







reply via email to

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