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 <br...@clisp.org> 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 <t...@jupiterrise.com>. --- 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 -@item The @code{HOST_NAME_MAX} macro is not defined on some platforms: +@item +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 +@item +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. +@item +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. +@item +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>