bug-gnulib
[Top][All Lists]
Advanced

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

Re: lib/dirent.in.h fails on AIX


From: Bruno Haible
Subject: Re: lib/dirent.in.h fails on AIX
Date: Thu, 20 Nov 2008 23:42:24 +0100
User-agent: KMail/1.5.4

Hello Albert,

> (AIX 6.1)
>   $ cat conftest.c
>   #include "///usr/vac/include/math.h"
>   int a = HUGE_VAL;
>   $ xlc -D_ALL_SOURCE -E conftest.c | tail
>   #line 2 "conftest.c"
>   int a = HUGE_VAL;
> ...
> /usr/vac/include/math.h includes /usr/include/math.h with:
>   #include_next <math.h>
> 
> I have no idea why:
>   #include <math.h>
> behaves differently than:
>   #include "///usr/vac/include/math.h"
> You'd figure with the #include_next <math.h> in /usr/vac/include/math.h
> the behavior would be the same. However, the #include_next <math.h> in
> /usr/vac/include/math.h is turned into a no-op.

Thanks for this problem summary. Since #include <math.h> works, it's not
a problem with the inclusion guards (the "#ifdef _H_MATH" or similar), but
- as you say - a problem with #include_next itself.

What's the result of
  $ grep include_next /usr/vac/include/*.h /usr/vac/include/*/*.h
?

Probably the only solution is to use #include_next only in gnulib's math.in.h
but not in the other header files that are overridden by gnulib. I'm applying
this; please let us know whether it works.

Bruno


2008-11-20  Bruno Haible  <address@hidden>

        Attempt to work around an AIX 5.3, 6.1 compiler bug with include_next.
        * lib/math.in.h: Use INCLUDE_NEXT_AS_FIRST_DIRECTIVE instead of
        INCLUDE_NEXT.
        * m4/include_next.m4 (gl_INCLUDE_NEXT): Set also
        INCLUDE_NEXT_AS_FIRST_DIRECTIVE.
        * modules/math (Makefile.am): Substitute
        INCLUDE_NEXT_AS_FIRST_DIRECTIVE instead of INCLUDE_NEXT.
        Reported by Albert Chin <address@hidden>.

--- lib/math.in.h.orig  2008-11-20 23:29:33.000000000 +0100
+++ lib/math.in.h       2008-11-20 23:26:08.000000000 +0100
@@ -22,7 +22,7 @@
 #endif
 
 /* The include_next requires a split double-inclusion guard.  */
address@hidden@ @NEXT_MATH_H@
address@hidden@ @NEXT_MATH_H@
 
 #ifndef _GL_MATH_H
 #define _GL_MATH_H
--- m4/include_next.m4.orig     2008-11-20 23:40:29.000000000 +0100
+++ m4/include_next.m4  2008-11-20 23:36:44.000000000 +0100
@@ -1,4 +1,4 @@
-# include_next.m4 serial 9
+# include_next.m4 serial 10
 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,6 +11,10 @@
 dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
 dnl 'include' otherwise.
 dnl
+dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
+dnl supports it in the special case that it is the first include directive in
+dnl the given file, or to 'include' otherwise.
+dnl
 dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
 dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
 dnl '#pragma GCC system_header' has the same effect as if the file was found
@@ -26,12 +30,26 @@
   AC_LANG_PREPROC_REQUIRE()
   AC_CACHE_CHECK([whether the preprocessor supports include_next],
     [gl_cv_have_include_next],
-    [rm -rf conftestd1 conftestd2
-     mkdir conftestd1 conftestd2
+    [rm -rf conftestd1a conftestd1b conftestd2
+     mkdir conftestd1a conftestd1b conftestd2
      dnl The include of <stdio.h> is because IBM C 9.0 on AIX 6.1 supports
      dnl include_next when used as first preprocessor directive in a file,
-     dnl but not when preceded by another include directive.
-     cat <<EOF > conftestd1/conftest.h
+     dnl but not when preceded by another include directive. Additionally,
+     dnl with this same compiler, include_next is a no-op when used in a
+     dnl header file that was included by specifying its absolute file name.
+     dnl Despite these two bugs, include_next is used in the compiler's
+     dnl <math.h>. By virtue of the second bug, we need to use include_next
+     dnl as well in this case.
+     cat <<EOF > conftestd1a/conftest.h
+#define DEFINED_IN_CONFTESTD1
+#include_next <conftest.h>
+#ifdef DEFINED_IN_CONFTESTD2
+int foo;
+#else
+#error "include_next doesn't work"
+#endif
+EOF
+     cat <<EOF > conftestd1b/conftest.h
 #define DEFINED_IN_CONFTESTD1
 #include <stdio.h>
 #include_next <conftest.h>
@@ -47,24 +65,36 @@
 #endif
 #define DEFINED_IN_CONFTESTD2
 EOF
-     save_CPPFLAGS="$CPPFLAGS"
-     CPPFLAGS="$CPPFLAGS -Iconftestd1 -Iconftestd2"
+     gl_save_CPPFLAGS="$CPPFLAGS"
+     CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
      AC_COMPILE_IFELSE([#include <conftest.h>],
        [gl_cv_have_include_next=yes],
-       [gl_cv_have_include_next=no])
-     CPPFLAGS="$save_CPPFLAGS"
-     rm -rf conftestd1 conftestd2
+       [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
+        AC_COMPILE_IFELSE([#include <conftest.h>],
+          [gl_cv_have_include_next=buggy],
+          [gl_cv_have_include_next=no])
+       ])
+     CPPFLAGS="$gl_save_CPPFLAGS"
+     rm -rf conftestd1a conftestd1b conftestd2
     ])
   PRAGMA_SYSTEM_HEADER=
   if test $gl_cv_have_include_next = yes; then
     INCLUDE_NEXT=include_next
+    INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
     if test -n "$GCC"; then
       PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
     fi
   else
-    INCLUDE_NEXT=include
+    if test $gl_cv_have_include_next = buggy; then
+      INCLUDE_NEXT=include
+      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
+    else
+      INCLUDE_NEXT=include
+      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
+    fi
   fi
   AC_SUBST([INCLUDE_NEXT])
+  AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
   AC_SUBST([PRAGMA_SYSTEM_HEADER])
 ])
 
--- modules/math.orig   2008-11-20 23:29:33.000000000 +0100
+++ modules/math        2008-11-20 23:26:18.000000000 +0100
@@ -20,7 +20,7 @@
 math.h: math.in.h
        rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+         sed -e 
's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''NEXT_MATH_H''@|$(NEXT_MATH_H)|g' \
              -e 's|@''GNULIB_CEILF''@|$(GNULIB_CEILF)|g' \





reply via email to

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