[Top][All Lists]

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

bug#9025: 24.0.50; gnulib defines intmax_t to int64_t on OSX, causes war

From: Jan Djärv
Subject: bug#9025: 24.0.50; gnulib defines intmax_t to int64_t on OSX, causes warnings and confusion.
Date: Sat, 09 Jul 2011 13:18:50 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:5.0) Gecko/20110624 Thunderbird/5.0

Paul Eggert skrev 2011-07-09 12.01:
[Following up<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9025>
and cc'ing to bug-gnulib:]

Jan Djärv writes:

Somewhere in gnulib, intmax_t gets defined to int64_t thus causing
compiler warnings and general confusion (the code says intmax_t but is
really int64_t).  AFAIK, all versions of OSX have intmax_t.

Thanks for reporting this.  I assume that intmax_t is 'long long'
whereas int64_t is 'long'?  If not, what are those two types defined
to in the system? and by gnulib?


typedef long long            int64_t;


#ifndef _INTMAX_T
#define _INTMAX_T
#ifdef __INTMAX_TYPE__
typedef __INTMAX_TYPE__             intmax_t;
#else /* __INTMAX_TYPE__ */
typedef long long                intmax_t;
#endif /* __INTMAX_TYPE__ */
#endif /* _INTMAX_T */

I don't know where __INTMAX_TYPE__ is defined, but looking at preprocessed output gives:

typedef long int intmax_t;

Which compiler and OS version are you using?

% gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /var/tmp/gcc/gcc-5664~89/src/configure --disable-checking --enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5664)

OSX 10.6.8.

Does the following (untested) patch to lib/stdint.in.h fix your problem?

Yes it does.

        Jan D.

diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index c44401f..0dd60b9 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -270,6 +270,11 @@ typedef unsigned long int gl_uintptr_t;
  /* Note: These types are compiler dependent. It may be unwise to use them in
     public header files. */

+/* If the system defines INTMAX_MAX, assume that intmax_t works, and
+   similarly for UINTMAX_MAX and uintmax_t.  This avoids problems with
+   assuming one type where another is used by the system.  */
+#ifndef INTMAX_MAX
  #undef intmax_t
  #if @HAVE_LONG_LONG_INT@&&  LONG_MAX>>  30 == 1
  typedef long long int gl_intmax_t;
@@ -280,7 +285,9 @@ typedef long long int gl_intmax_t;
  typedef long int gl_intmax_t;
  # define intmax_t gl_intmax_t

+#ifndef UINTMAX_MAX
  #undef uintmax_t
  typedef unsigned long long int gl_uintmax_t;
@@ -291,6 +298,7 @@ typedef unsigned long long int gl_uintmax_t;
  typedef unsigned long int gl_uintmax_t;
  # define uintmax_t gl_uintmax_t

  /* Verify that intmax_t and uintmax_t have the same size.  Too much code
     breaks if this is not the case.  If this check fails, the reason is likely
@@ -431,8 +439,8 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof 

  /* Limits of greatest-width integer types */

+#ifndef INTMAX_MAX
  #undef INTMAX_MIN
-#undef INTMAX_MAX
  #ifdef INT64_MAX
  # define INTMAX_MIN  INT64_MIN
  # define INTMAX_MAX  INT64_MAX
@@ -440,13 +448,15 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == 
sizeof (uintmax_t)
  # define INTMAX_MIN  INT32_MIN
  # define INTMAX_MAX  INT32_MAX

+#ifndef UINTMAX_MAX
  #ifdef UINT64_MAX
  # define UINTMAX_MAX  UINT64_MAX
  # define UINTMAX_MAX  UINT32_MAX

  /* 7.18.3. Limits of other integer types */

reply via email to

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