bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] stdint: avoid HP-UX 10.20 preprocessor bug


From: Eric Blake
Subject: [PATCH] stdint: avoid HP-UX 10.20 preprocessor bug
Date: Fri, 24 Dec 2010 13:41:29 -0700

* lib/stdint.in.h (INT64_MAX, UINT64_MAX): Check via #ifdef rather
than #if.
* tests/test-floor2.c (main): Likewise.
Reported by Peter O'Gorman.

Signed-off-by: Eric Blake <address@hidden>
---

> 
>> +#if UINT64_MAX
>>  # define GL_UINT64_T
>  
> Any reason not to #ifdef INT64_MAX/UINT64_MAX instead of plain #if? With
> just #if we get preprocessor errors on hpux10.20 with hp cc:

Thanks for the report.  When both forms work, #if is shorter than
#ifdef, and proves that the argument is either undefined or numeric,
which is why we prefer it.  But since you have a proven case of a
preprocessor bug where the workaround is easy enough to implement, we
might as well go with the workaround and document why we did so.

> cpp: "stdint.h", line 143: warning 2012: Unrepresentable preprocessor
> number 9223372036854775807ll.

I'm pushing this.

 ChangeLog           |    6 ++++++
 lib/stdint.in.h     |    7 ++++---
 tests/test-floor2.c |    2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 28d6819..b0ddade 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-12-24  Eric Blake  <address@hidden>

+       stdint: avoid HP-UX 10.20 preprocessor bug
+       * lib/stdint.in.h (INT64_MAX, UINT64_MAX): Check via #ifdef rather
+       than #if.
+       * tests/test-floor2.c (main): Likewise.
+       Reported by Peter O'Gorman.
+
        pipe: make obsoletion transition easier
        * lib/pipe.h: Restore file as thin shim around "spawn-pipe.h".
        * modules/pipe (Files): Include revived file.
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 70822b8..7270ad0 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -137,9 +137,10 @@ typedef unsigned int gl_uint32_t;
 /* If the system defines INT64_MAX, assume int64_t works.  That way,
    if the underlying platform defines int64_t to be a 64-bit long long
    int, the code below won't mistakenly define it to be a 64-bit long
-   int, which would mess up C++ name mangling.  */
+   int, which would mess up C++ name mangling.  We must use #ifdef
+   rather than #if, to avoid an error with HP-UX 10.20 cc.  */

-#if INT64_MAX
+#ifdef INT64_MAX
 # define GL_INT64_T
 #else
 /* Do not undefine int64_t if gnulib is not being used with 64-bit
@@ -162,7 +163,7 @@ typedef long long int gl_int64_t;
 # endif
 #endif

-#if UINT64_MAX
+#ifdef UINT64_MAX
 # define GL_UINT64_T
 #else
 # if ULONG_MAX >> 31 >> 31 >> 1 == 1
diff --git a/tests/test-floor2.c b/tests/test-floor2.c
index e239199..971f24a 100644
--- a/tests/test-floor2.c
+++ b/tests/test-floor2.c
@@ -144,7 +144,7 @@ check (double x)
 int
 main ()
 {
-#if UINT64_MAX
+#ifdef UINT64_MAX
   unsigned int highbits;
   unsigned int lowbits;
   int error = 0;
-- 
1.7.3.4




reply via email to

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