We recently built poppler-0.5.4, a C++ library, and had to bring in
gnulib for snprintf() on Tru64 UNIX. Because of this, lib/string_.h ->
lib/string.h which the HP C++ compiler has a problem with. On 11.x/PA,
the HP C++ compiler does not support #include_next. So, we get
#include "///usr/include/string.h". This fails to include the
C++-specific <string.h> and thus some functions like strchr() don't
get defined, leading to compile failures. When you #include <string.h>
in a C++ program, /opt/aCC/include/string.h is included first, which
then includes /usr/include/string.h (via <cstring>). The reverse
doesn't work.
So, do we need to compensate for this. I hacked up something to work
around this and have attached it.
--
albert chin ([EMAIL PROTECTED])
Index: lib/string_.h
===================================================================
--- lib/string_.h.orig 2007-09-01 16:44:18.805051431 +0000
+++ lib/string_.h 2007-09-01 16:45:28.184147958 +0000
@@ -19,7 +19,11 @@
#ifndef _GL_STRING_H
/* The include_next requires a split double-inclusion guard. */
+#ifdef __cplusplus
[EMAIL PROTECTED]@ @NEXT_STRING_H_CXX@
+#else
[EMAIL PROTECTED]@ @NEXT_STRING_H@
+#endif
#ifndef _GL_STRING_H
#define _GL_STRING_H
Index: m4/include_next.m4
===================================================================
--- m4/include_next.m4.orig 2007-09-01 16:44:18.868161169 +0000
+++ m4/include_next.m4 2007-09-01 16:45:28.193491133 +0000
@@ -105,3 +105,61 @@
[AS_VAR_GET([gl_next_header])])
AS_VAR_POPDEF([gl_next_header])])
])
+
+# gl_CHECK_NEXT_HEADERS_CXX(HEADER1 HEADER2 ...)
+# ------------------------------------------
+# For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
+# '<foo.h>'; otherwise define it to be
+# '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
+# That way, a header file with the following line:
+# [EMAIL PROTECTED]@ @NEXT_FOO_H_CXX@
+# behaves (after sed substitution) as if it contained
+# #include_next <foo.h>
+# even if the compiler does not support include_next.
+# The three "///" are to pacify Sun C 5.8, which otherwise would say
+# "warning: #include of /usr/include/... may be non-portable".
+# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
+AC_DEFUN([gl_CHECK_NEXT_HEADERS_CXX],
+[
+ AC_REQUIRE([gl_INCLUDE_NEXT])
+ AC_CHECK_HEADERS_ONCE([$1])
+
+ AC_FOREACH([gl_HEADER_NAME], [$1],
+ [AS_VAR_PUSHDEF([gl_next_header],
+ [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME]))[_cxx])
+ AC_LANG_PUSH([C++])
+ if test $gl_cv_have_include_next = yes; then
+ AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
+ else
+ AC_CACHE_CHECK(
+ [absolute name of C++ <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
+ m4_quote(m4_defn([gl_next_header])),
+ [AS_VAR_PUSHDEF([gl_header_exists],
+ [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
+ if test AS_VAR_GET(gl_header_exists) = yes; then
+ AC_LANG_CONFTEST(
+ [AC_LANG_SOURCE(
+ [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
+ )])
+ dnl eval is necessary to expand ac_cpp.
+ dnl Ultrix and Pyramid sh refuse to redirect output of eval,
+ dnl so use subshell.
+ AS_VAR_SET([gl_next_header],
+ ['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
+ sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
+ s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
+ s#^/[^/]#//&#
+ p
+ q
+ }'`'"'])
+ else
+ AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
+ fi
+ AS_VAR_POPDEF([gl_header_exists])])
+ fi
+ AC_SUBST(
+ AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))[_CXX]),
+ [AS_VAR_GET([gl_next_header])])
+ AC_LANG_POP([C++])
+ AS_VAR_POPDEF([gl_next_header])])
+])
Index: m4/string_h.m4
===================================================================
--- m4/string_h.m4.orig 2007-09-01 16:44:18.878137121 +0000
+++ m4/string_h.m4 2007-09-01 16:45:28.200304234 +0000
@@ -19,6 +19,8 @@
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
gl_CHECK_NEXT_HEADERS([string.h])
+ AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [gl_CHECK_NEXT_HEADERS_CXX([string.h])])
])
AC_DEFUN([gl_STRING_MODULE_INDICATOR],