On 05/07/2012 10:13 AM, Niels Möller wrote:
> I thought the point of gnulib was to do those annoying things to keep
> the maintanance in one place.

True.  Very true.

OK, how about the following patch to gnulib's lib/stdint.in.h?
Does it fix the problem?

And if not, could you please explain what goes wrong?
I'm still not quite understanding the pattern of includes
that causes the compilation failure.  Thanks.

---
 ChangeLog       |   15 +++++++++++++++
 lib/stdint.in.h |   49 +++++++++++++++++++++++++++++++++----------------
 2 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a05f41d..f285344 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2012-05-07  Paul Eggert  <egg...@cs.ucla.edu>
+
+       stdint: be more consistent with glibc, SunOS libc
+       * lib/stdint.in.h (gl_int_fast8_t, gl_uint_fast8_t)
+       (gl_int_fast16_t, gl_uint_fast16_t)
+       (gl_int_fast32_t, gl_uint_fast32_t)
+       (INT_FAST8_MIN, INT_FAST8_MAX, UINT_FAST8_MAX)
+       (INT_FAST16_MIN, INT_FAST16_MAX, UINT_FAST16_MAX)
+       (INT_FAST32_MIN, INT_FAST32_MAX, UINT_FAST32_MAX):
+       Be consistent with glibc by default, and with SunOS 5.10 and later
+       if __sun is defined.  This lessens the likelihood of clashes if
+       code compiled for older hosts is combined with code compiled for
+       newer ones.  Problem reported by Niels Möller in
+       <http://lists.gnu.org/archive/html/bug-gnulib/2012-05/msg00074.html>.
+
 2012-05-06  Paul Eggert  <egg...@cs.ucla.edu>
 
        stat-size: comment fix
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 54ec7e0..9a82ae7 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -90,7 +90,8 @@
 # include <sys/types.h>
 #endif
 
-/* Get LONG_MIN, LONG_MAX, ULONG_MAX.  */
+/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
+   LONG_MIN, LONG_MAX, ULONG_MAX.  */
 #include <limits.h>
 
 #if @HAVE_INTTYPES_H@
@@ -246,8 +247,9 @@ typedef unsigned long long int gl_uint64_t;
 
 /* Here we assume a standard architecture where the hardware integer
    types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
-   are taken from the same list of types.  Assume that 'long int'
-   is fast enough for all narrower integers.  */
+   are taken from the same list of types.  The following code normally
+   uses types consistent with glibc, as that lessens the chance of
+   incompatibility with older GNU hosts.  */
 
 #undef int_fast8_t
 #undef uint_fast8_t
@@ -257,12 +259,21 @@ typedef unsigned long long int gl_uint64_t;
 #undef uint_fast32_t
 #undef int_fast64_t
 #undef uint_fast64_t
-typedef long int gl_int_fast8_t;
-typedef unsigned long int gl_uint_fast8_t;
-typedef long int gl_int_fast16_t;
-typedef unsigned long int gl_uint_fast16_t;
+typedef signed char gl_int_fast8_t;
+typedef unsigned char gl_uint_fast8_t;
+
+#ifdef __sun
+/* Define types compatible with SunOS 5.10, so that code compiled under
+   earlier SunOS versions works with code compiled under SunOS 5.10.  */
+typedef int gl_int_fast32_t;
+typedef unsigned int gl_uint_fast32_t;
+#else
 typedef long int gl_int_fast32_t;
 typedef unsigned long int gl_uint_fast32_t;
+#endif
+typedef gl_int_fast32_t gl_int_fast16_t;
+typedef gl_uint_fast32_t gl_uint_fast16_t;
+
 #define int_fast8_t gl_int_fast8_t
 #define uint_fast8_t gl_uint_fast8_t
 #define int_fast16_t gl_int_fast16_t
@@ -418,23 +429,29 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == 
sizeof (uintmax_t)
 #undef INT_FAST8_MIN
 #undef INT_FAST8_MAX
 #undef UINT_FAST8_MAX
-#define INT_FAST8_MIN  LONG_MIN
-#define INT_FAST8_MAX  LONG_MAX
-#define UINT_FAST8_MAX  ULONG_MAX
+#define INT_FAST8_MIN  SCHAR_MIN
+#define INT_FAST8_MAX  SCHAR_MAX
+#define UINT_FAST8_MAX  UCHAR_MAX
 
 #undef INT_FAST16_MIN
 #undef INT_FAST16_MAX
 #undef UINT_FAST16_MAX
-#define INT_FAST16_MIN  LONG_MIN
-#define INT_FAST16_MAX  LONG_MAX
-#define UINT_FAST16_MAX  ULONG_MAX
+#define INT_FAST16_MIN  INT_FAST32_MIN
+#define INT_FAST16_MAX  INT_FAST32_MAX
+#define UINT_FAST16_MAX  UINT_FAST32_MAX
 
 #undef INT_FAST32_MIN
 #undef INT_FAST32_MAX
 #undef UINT_FAST32_MAX
-#define INT_FAST32_MIN  LONG_MIN
-#define INT_FAST32_MAX  LONG_MAX
-#define UINT_FAST32_MAX  ULONG_MAX
+#ifdef __sun
+# define INT_FAST32_MIN  INT_MIN
+# define INT_FAST32_MAX  INT_MAX
+# define UINT_FAST32_MAX  UINT_MAX
+#else
+# define INT_FAST32_MIN  LONG_MIN
+# define INT_FAST32_MAX  LONG_MAX
+# define UINT_FAST32_MAX  ULONG_MAX
+#endif
 
 #undef INT_FAST64_MIN
 #undef INT_FAST64_MAX
-- 
1.7.6.5


Reply via email to