This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] stdint: Use __extension__ on long long constants


Most uses of long long in stdint.h are guarded with __extension__ to prevent them from issuing warnings with -std=c89 -pedantic. However, on 32-bit platforms the 64-bit integer constant macros append LL or ULL without marking it as an __extension__.

As a result, GCC issues this warning:

    $ gcc -m32 -std=c89 -pedantic -c -o stdintext.o stdintext.c
    In file included from stdint.h:9:0,
                     from stdintext.c:1:
stdintext.c:3:23: warning: use of C99 long long integer constant [-Wlong-long]
     uint64_t i = UINT64_C(0);

Prefix all ## LL and ## ULL macros with __extension__ to suppress these warnings.
---
 stdlib/stdint.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/stdlib/stdint.h b/stdlib/stdint.h
index 2df07e485b..9fa45672db 100644
--- a/stdlib/stdint.h
+++ b/stdlib/stdint.h
@@ -106,8 +106,8 @@ typedef __uintmax_t         uintmax_t;
 #  define __INT64_C(c) c ## L
 #  define __UINT64_C(c)        c ## UL
 # else
-#  define __INT64_C(c) c ## LL
-#  define __UINT64_C(c)        c ## ULL
+#  define __INT64_C(c) (__extension__ c ## LL)
+#  define __UINT64_C(c)        (__extension__ c ## ULL)
 # endif

 /* Limits of integral types.  */
@@ -251,7 +251,7 @@ typedef __uintmax_t         uintmax_t;
 # if __WORDSIZE == 64
 #  define INT64_C(c)   c ## L
 # else
-#  define INT64_C(c)   c ## LL
+#  define INT64_C(c)   (__extension__ c ## LL)
 # endif

 /* Unsigned.  */
@@ -261,7 +261,7 @@ typedef __uintmax_t         uintmax_t;
 # if __WORDSIZE == 64
 #  define UINT64_C(c)  c ## UL
 # else
-#  define UINT64_C(c)  c ## ULL
+#  define UINT64_C(c)  (__extension__ c ## ULL)
 # endif

 /* Maximal type.  */
@@ -269,8 +269,8 @@ typedef __uintmax_t         uintmax_t;
 #  define INTMAX_C(c)  c ## L
 #  define UINTMAX_C(c) c ## UL
 # else
-#  define INTMAX_C(c)  c ## LL
-#  define UINTMAX_C(c) c ## ULL
+#  define INTMAX_C(c)  (__extension__ c ## LL)
+#  define UINTMAX_C(c) (__extension__ c ## ULL)
 # endif

 #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]