Submitter: Douglas A. Gwyn (J11)
Submission Date: 1999-10-19
Source:
Reference Document: ISO/IEC WG14 N896
Version: 1.2
Date: 2000-11-02 13:46:31
Subject: Problem implementing INTN_C macros
Summary
The requirements of subclause 7.18.4.1 may be impossible to satisfy
(for N = 8 or 16, typically)
unless an implementation has special (non-standard) support
for integer constants of types char and short:
The macro INTN_C(value) shall expand to a signed integer constant with the specified value and type int_leastN_t.(Similarly for UINTN_C.) The paragraph preceding this overly restrictive specification reflects the actual intent:
... a type with at least the specified width.
Possible Solutions
Suggested Technical Correction
In subclause 7.18.4.1 paragraph 2,
change the two occurrences of "and type"
to
"and [un]signed integer type at least as wide as".
Technical Corrigendum
7.18.4 Macros for integer constants
[#1] The following function-like macros220 expand to integer constant expressions suitable for initializing objects that have integer types corresponding to types defined in <stdint.h>. Each macro name corresponds to a similar type name in 7.18.1.2 or 7.18.1.5.Add:[#2] The argument in any instance of these macros shall be a decimal, octal, or hexadecimal constant (as defined in 6.4.4.1) with a value that does not exceed the limits for the corresponding type.
[#3] Each invocation of one of these macros shall expand to an integer constant expression suitable for use in #if preprocessing directives. The type of the expression shall have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. The value of the expression shall be that of the argument.
Most of the following wording is taken almost exactly from <limits.h>
7.18.4.1 Macros for minimum-width integer constants
Remove:
[#1] Each of the following macros expands to an integer constant having the value specified by its argument and a type with at least the specified width.221)221 For each name described in 7.18.1.2 that the implementation provides, the corresponding macro in this subclause is required.
Change [#2] to:
[#2] 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.
7.18.4.2 Macros for greatest-width integer constants
[#1] The following macro expands to an integer constant expression having the value specified by its argument and the type intmax_t:INTMAX_C(value)The following macro expands to an integer constant expression having the value specified by its argument and the type uintmax_t:UINTMAX_C(value)