bug-gnulib
[Top][All Lists]
Advanced

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

Re: fix compilation error in C++ mode on HP-UX 11


From: Bruno Haible
Subject: Re: fix compilation error in C++ mode on HP-UX 11
Date: Mon, 09 Dec 2019 02:23:14 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

> On HP-UX 11, a testdir built with --with-c++-tests produces a number of
> errors

On HP-UX 11/ia64, in 32-bit mode, there is another set of errors:

source='../../gltests/test-stdio-c++.cc' object='test-stdio-c++.o' libtool=no \
DEPDIR=.deps depmode=hp2 /bin/sh ../../build-aux/depcomp \
aCC -O -D_HPUX_SOURCE -D_XOPEN_SOURCE=600 -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. 
-I../../gltests -I..  -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. 
-I../../gltests -I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib 
-I/home/haible/prefix-hpux113ia64-32-cc/include   -c -o test-stdio-c++.o 
../../gltests/test-stdio-c++.cc
"../gllib/stdio.h", line 1020: error #2282: the global scope has no "fseeko"
  _GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
                    ^

"../gllib/stdio.h", line 1081: error #2282: the global scope has no "ftello"
  _GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
                    ^

2 errors detected in the compilation of "../../gltests/test-stdio-c++.cc".
gmake[2]: *** [test-stdio-c++.o] Error 2


The cause is that on this system, <stdio.h> declares fseeko and ftello in
C++ mode only if _LARGEFILE_SOURCE is defined. Therefore, the use of
gnulib module 'fseeko' or 'ftello' ought to ensure that _LARGEFILE_SOURCE
is defined. But the logic in AC_SYS_LARGEFILE does not do this (it sets
only _FILE_OFFSET_BITS and _LARGE_FILES), and AC_FUNC_FSEEKO which is meant
to set _LARGEFILE_SOURCE does not do it because it uses a test program for
the C compiler, not for the C++ compiler.

This patch fixes it.


2019-12-08  Bruno Haible  <address@hidden>

        Fix compilation errors in 32-bit C++ mode on HP-UX 11/ia64.
        * m4/largefile.m4 (gl_SET_LARGEFILE_SOURCE): New macro.
        * modules/fseeko (configure.ac-early): Require it instead of
        AC_FUNC_FSEEKO.
        * modules/ftello (configure.ac-early): Likewise.
        * modules/fflush (configure.ac-early): Likewise.

diff --git a/m4/largefile.m4 b/m4/largefile.m4
index c6dd9a1..65d5a15 100644
--- a/m4/largefile.m4
+++ b/m4/largefile.m4
@@ -5,6 +5,22 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# The following macro works around a problem in Autoconf's AC_FUNC_FSEEKO:
+# It does not set _LARGEFILE_SOURCE=1 on HP-UX/ia64 32-bit, although this
+# setting of _LARGEFILE_SOURCE is needed so that <stdio.h> declares fseeko
+# and ftello in C++ mode as well.
+AC_DEFUN([gl_SET_LARGEFILE_SOURCE],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_FUNC_FSEEKO
+  case "$host_os" in
+    hpux*)
+      AC_DEFINE([_LARGEFILE_SOURCE], [1],
+        [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).])
+      ;;
+  esac
+])
+
 # The following implementation works around a problem in autoconf <= 2.69;
 # AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5,
 # or configures them incorrectly in some cases.
diff --git a/modules/fflush b/modules/fflush
index 03b2f1d..858a25a 100644
--- a/modules/fflush
+++ b/modules/fflush
@@ -17,7 +17,7 @@ unistd                    [test $REPLACE_FFLUSH = 1]
 fseeko                    [test $REPLACE_FFLUSH = 1]
 
 configure.ac-early:
-AC_REQUIRE([AC_FUNC_FSEEKO])
+AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
 
 configure.ac:
 gl_FUNC_FFLUSH
diff --git a/modules/fseeko b/modules/fseeko
index d4cc162..83db09c 100644
--- a/modules/fseeko
+++ b/modules/fseeko
@@ -16,7 +16,7 @@ sys_types
 fseek
 
 configure.ac-early:
-AC_REQUIRE([AC_FUNC_FSEEKO])
+AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
 
 configure.ac:
 gl_FUNC_FSEEKO
diff --git a/modules/ftello b/modules/ftello
index 1680f2d..6de0859 100644
--- a/modules/ftello
+++ b/modules/ftello
@@ -17,7 +17,7 @@ lseek           [test $HAVE_FTELLO = 0 || test 
$REPLACE_FTELLO = 1]
 ftell
 
 configure.ac-early:
-AC_REQUIRE([AC_FUNC_FSEEKO])
+AC_REQUIRE([gl_SET_LARGEFILE_SOURCE])
 
 configure.ac:
 gl_FUNC_FTELLO




reply via email to

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