bug-gnulib
[Top][All Lists]
Advanced

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

Re: xstrtoll.c build error on Tru64 5.1B


From: Bruno Haible
Subject: Re: xstrtoll.c build error on Tru64 5.1B
Date: Sat, 15 Oct 2011 17:14:12 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

Hi,

Tom G. Christensen wrote:
> The xstrtoll module fails to build on Tru64:
> 
> source='xstrtoll.c' object='xstrtoll.o' libtool=no \
>          DEPDIR=.deps depmode=tru64 /bin/ksh ../build-aux/depcomp \
>          cc -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1   -g -c 
> xstrtoll.c
> cc: Error: xstrtol.c, line 49: In this statement, "LLONG_MIN" is not 
> declared. (undeclared)
>    if (TYPE_SIGNED (__strtol_t) && *x < STRTOL_T_MINIMUM / scale_factor)
> ---------------------------------------^
> cc: Error: xstrtol.c, line 54: In this statement, "LLONG_MAX" is not 
> declared. (undeclared)
>    if (STRTOL_T_MAXIMUM / scale_factor < *x)
> ------^
> make[4]: *** [xstrtoll.o] Error 1
> 
> The problem is that LLONG_MIN, LLONG_MAX and ULLONG_MAX are only defined 
> in strtol.c.
> Copying their definitions from strtol.c into xstrtol.c fixed the build 
> error (and the tests pass).

Thanks for the report. The same compilation failure exists on
AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1 with gcc (although I cannot
reproduce it with OSF/1 5.1 with cc; I must be using a saner cc
than you). 

This patch fixes it. I'm also adding a piece of documentation about
the problems of <limits.h>.

Note that gnulib does not have a replacement module for <limits.h>,
because
  - The usual wrapping technique would not work for <limits.h>,
    hence the workaround definitions would have to be added to config.h,
  - It's easier to work around these problems in the .c files rather
    than through autoconf tests that would add the missing defines to
    config.h.


2011-10-15  Bruno Haible  <address@hidden>

        xstrtoll: Fix compilation failure.
        * lib/xstrtol.c (ULLONG_MAX, LLONG_MAX, LLONG_MIN): New macros, taken
        from lib/strtol.c.
        * doc/posix-headers/limits.texi: Mention missing numerical limits on
        some platforms.
        Reported by Tom G. Christensen <address@hidden>.

--- doc/posix-headers/limits.texi.orig  Sat Oct 15 17:05:31 2011
+++ doc/posix-headers/limits.texi       Sat Oct 15 16:14:43 2011
@@ -7,13 +7,24 @@
 
 Portability problems fixed by Gnulib:
 @itemize
address@hidden The @code{HOST_NAME_MAX} macro is not defined on some platforms:
address@hidden
+The @code{HOST_NAME_MAX} macro is not defined on some platforms:
 MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 5.1, HP-UX 11,
 IRIX 6.5, OSF/1 5.1, Solaris 11 2010-11, Cygwin 1.5.x, mingw, MSVC 9, Interix 
3.5, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
address@hidden
+The macros @code{LLONG_MIN}, @code{LLONG_MAX}, @code{ULLONG_MAX} are not
+defined on some platforms:
+AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1 with gcc.
address@hidden
+The macros @code{WORD_BIT}, @code{LONG_BIT} are not defined on some platforms:
+glibc 2.11 without @code{-D_GNU_SOURCE}, Cygwin, mingw, MSVC 9.
address@hidden
+The macro @code{SSIZE_MAX} is not defined on some platforms:
+MSVC 9.
 @end itemize
 
 For @code{PATH_MAX}, Gnulib provides a module @code{pathmax} with a header
--- lib/xstrtol.c.orig  Sat Oct 15 17:05:31 2011
+++ lib/xstrtol.c       Sat Oct 15 16:46:59 2011
@@ -43,6 +43,19 @@
 
 #include "intprops.h"
 
+/* xstrtoll.c and xstrtoull.c, which include this file, require that
+   ULLONG_MAX, LLONG_MAX, LLONG_MIN are defined, but <limits.h> does not
+   define them on all platforms.  */
+#ifndef ULLONG_MAX
+# define ULLONG_MAX TYPE_MAXIMUM (unsigned long long)
+#endif
+#ifndef LLONG_MAX
+# define LLONG_MAX TYPE_MAXIMUM (long long int)
+#endif
+#ifndef LLONG_MIN
+# define LLONG_MIN TYPE_MINIMUM (long long int)
+#endif
+
 static strtol_error
 bkm_scale (__strtol_t *x, int scale_factor)
 {

-- 
In memoriam Thomas Sankara <http://en.wikipedia.org/wiki/Thomas_Sankara>



reply via email to

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