Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
INTx_C/UINTx_C definitions result type
Hi,
I just noted that INTx_C/UINTx_C macros does not seems to return
costants of the specified `uint_leastx_t' type as expected ...
7.18.4.1 Macros for minimum-width integer constants
1 The macro INTN_C(value) shall expand to an integer constant
expression corresponding to the type int_leastN_t. The macro
UINTN_C(value) shall expand to an integer constant expression
corresponding to the type uint_leastN_t. For example, if
uint_least64_t is a name for the type unsigned long long int, then
UINT64_C(0x123) might expand to the integer constant 0x123ULL.
Actually only the smallest version (x < 32) suffers from this and
sizeof(INT8_C(0)) = 4 differs from sizeof(int_least8_t) = 1.
Any drawbacks to be expected with the following patch that adds casts
for the corresponding types ?
Thanks.
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.
Index: sys/arch/amd64/include/int_const.h
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/include/int_const.h,v
retrieving revision 1.4
diff -u -p -r1.4 int_const.h
--- sys/arch/amd64/include/int_const.h 29 May 2010 17:33:57 -0000 1.4
+++ sys/arch/amd64/include/int_const.h 5 Dec 2010 21:07:34 -0000
@@ -40,15 +40,15 @@
/* 7.18.4.1 Macros for minimum-width integer constants */
-#define INT8_C(c) c
-#define INT16_C(c) c
-#define INT32_C(c) c
-#define INT64_C(c) c ## L
-
-#define UINT8_C(c) c
-#define UINT16_C(c) c
-#define UINT32_C(c) c ## U
-#define UINT64_C(c) c ## UL
+#define INT8_C(c) (int_least8_t)c
+#define INT16_C(c) (int_least16_t)c
+#define INT32_C(c) (int_least32_t)c
+#define INT64_C(c) (int_least64_t)(c ## L)
+
+#define UINT8_C(c) (uint_least8_t)c
+#define UINT16_C(c) (uint_least16_t)c
+#define UINT32_C(c) (uint_least32_t)(c ## U)
+#define UINT64_C(c) (uint_least64_t)(c ## UL)
/* 7.18.4.2 Macros for greatest-width integer constants */
Home |
Main Index |
Thread Index |
Old Index