From ff853e010804e2fca70f1d6c726847c498169313 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Sat, 17 Jan 2004 07:41:54 +0000 Subject: [PATCH] * include/stdint.h Fix __STDC_CONSTANT_MACROS for 8 and 16 bit types. (Thanks to John Maddock for report.) --- winsup/mingw/ChangeLog | 5 +++++ winsup/mingw/include/stdint.h | 22 +++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index a1497cc62..de8109a4e 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,8 @@ +2004-01-16 Danny Smith + + * include/stdint.h Fix __STDC_CONSTANT_MACROS for 8 and 16 bit + types. (Thanks to John Maddock for report.) + 2004-01-14 Greg Chicares * include/tchar.h (_puttchar): Define. diff --git a/winsup/mingw/include/stdint.h b/winsup/mingw/include/stdint.h index 258002e3b..2ea752fa3 100644 --- a/winsup/mingw/include/stdint.h +++ b/winsup/mingw/include/stdint.h @@ -163,25 +163,21 @@ typedef unsigned long long uintmax_t; an integer constant with width less than that of type int. TC1 changed this to require just an integer constant *expression* with *promoted* type." - - The trick used here is from Clive D W Feather. */ -#define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val)) -#define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val)) -#define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val)) -/* The 'trick' doesn't work in C89 for long long because, without - suffix, (val) will be evaluated as int, not intmax_t */ -#define INT64_C(val) val##LL +#define INT8_C(val) ((int8_t) + (val)) +#define UINT8_C(val) ((uint8_t) + (val##U)) +#define INT16_C(val) ((int16_t) + (val)) +#define UINT16_C(val) ((uint16_t) + (val##U)) -#define UINT8_C(val) (UINT_LEAST8_MAX-UINT_LEAST8_MAX+(val)) -#define UINT16_C(val) (UINT_LEAST16_MAX-UINT_LEAST16_MAX+(val)) -#define UINT32_C(val) (UINT_LEAST32_MAX-UINT_LEAST32_MAX+(val)) +#define INT32_C(val) val##L +#define UINT32_C(val) val##UL +#define INT64_C(val) val##LL #define UINT64_C(val) val##ULL /* 7.18.4.2 Macros for greatest-width integer constants */ -#define INTMAX_C(val) val##LL -#define UINTMAX_C(val) val##ULL +#define INTMAX_C(val) INT64_C(val) +#define UINTMAX_C(val) UINT64_C(val) #endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */ -- 2.43.5