*_MIN, *_MAX, and *_WIDTH macros as integer constant expressionsAuthors: Jay Ghiron
Date: 2026-11-12
Submitted against: C23
Status: Open
Cross-references: 1056
The values given subsequently shall be replaced by constant expressions suitable for use in conditional expression inclusion preprocessing directives. Their implementation-defined values shall be equal or greater to those shown.
- width for an object of type
boolBOOL_WIDTH 1- number of bits for smallest object that is not a bit-field (byte)
The macrosCHAR_BIT 8CHAR_WIDTH,SCHAR_WIDTH, andUCHAR_WIDTHthat represent the width of the typeschar,signed charandunsigned charshall expand to the same value asCHAR_BIT.- width for an object of type
unsigned short intThe macroUSHRT_WIDTH 16SHRT_WIDTHrepresents the width of the typeshort intand shall expand to the same value asUSHRT_WIDTH.- width for an object of type
unsigned intThe macroUINT_WIDTH 16INT_WIDTHrepresents the width of the typeintand shall expand to the same value asUINT_WIDTH.- width for an object of type unsigned long int
The macroULONG_WIDTH 32LONG_WIDTHrepresents the width of the typelong intand shall expand to the same value asULONG_WIDTH.- width for an object of type
unsigned long long intThe macroULLONG_WIDTH 64LLONG_WIDTHrepresents the width of the typelong long intand shall expand to the same value asULLONG_WIDTH.- maximum width of a bit-precise integer type
The macroBITINT_MAXWIDTH /* see the following */BITINT_MAXWIDTHrepresents the maximum width N supported by the declaration of a bit-precise integer (6.2.5) in the type specifier_BitInt(N). The valueBITINT_MAXWIDTHshall expand to a value that is greater than or equal to the value ofULLONG_WIDTH.- maximum number of bytes in a multibyte character, for any supported locale
MB_LEN_MAX 1For all unsigned integer types for which
<limits.h>or<stdint.h>define a macro with suffix_WIDTHholding its width N, there is a macro with suffix_MAXholding the maximal value 2N − 1 that is representable by the type and that has the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. If the value is in the range of the typeuintmax_t(7.22.2.6) the macro is suitable for use in conditional expression inclusion preprocessing directives.For all signed integer types for which
<limits.h>or<stdint.h>define a macro with suffix_WIDTHholding its width N, there are macros with suffix_MINand_MAXholding the minimal and maximal values −2N − 1 and 2N − 1 − 1 that are representable by the type and that have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. If the values are in the range of the typeintmax_t(7.22.2.6) the macros are suitable for use in conditional expression inclusion preprocessing directives.If an object of type
charcan hold negative values, the value ofCHAR_MINshall be the same as that ofSCHAR_MINand the value ofCHAR_MAXshall be the same as that ofSCHAR_MAX. Otherwise, the value ofCHAR_MINshall be 0 and the value ofCHAR_MAXshall be the same as that ofUCHAR_MAX(see 6.2.5.).
(C23 5.3.5.3.2 "Characteristics of integer types <limits.h>".)
There does not appear to be anything that requires the *_MIN and
*_MAX macros derived from the *_WIDTH macros to expand to integer
constant expressions, though the requirements for some macros to be
usable in conditional expression inclusion preprocessing directives
could be interpreted as requiring integer constant expressions.
There also does not appear to be anything that requires the signed
*_WIDTH macros in <limits.h> and CHAR_WIDTH to expand to integer
constant expressions, this section only defines their values.
The following are a few asides that I noticed when making this issue:
#if preprocessing directives"
instead of "conditional expression inclusion preprocessing
directives": C23 7.22.3.1 paragraph 2, C23 7.22.4.1 paragraph 2,
and C23 E.2 paragraph 3. It would be useful to replace these
instances with the more usual wording.char do not have any definition of "value
representation". With
N3747
bool is also no longer an unsigned integer type and therefore
does not have a definition for its value representation.Modify C23 5.3.5.3.2:
The values given subsequently shall be replaced by integer constant expressions suitable for use in conditional expression inclusion preprocessing directives. Their implementation-defined values shall be equal or greater to those shown.
- width for an object of type
boolBOOL_WIDTH 1- number of bits for smallest object that is not a bit-field (byte)
The macrosCHAR_BIT 8CHAR_WIDTH,SCHAR_WIDTH, andUCHAR_WIDTHthat represent the width of the typeschar,signed charandunsigned charshall expand to the same value asCHAR_BITand be integer constant expressions suitable for use in conditional expression inclusion preprocessing directives.- width for an object of type
unsigned short intThe macroUSHRT_WIDTH 16SHRT_WIDTHrepresents the width of the typeshort intand shall expand to the same value asUSHRT_WIDTHand be an integer constant expression suitable for use in conditional expression inclusion preprocessing directives.- width for an object of type
unsigned intThe macroUINT_WIDTH 16INT_WIDTHrepresents the width of the typeintand shall expand to the same value asUINT_WIDTHand be an integer constant expression suitable for use in conditional expression inclusion preprocessing directives.- width for an object of type unsigned long int
The macroULONG_WIDTH 32LONG_WIDTHrepresents the width of the typelong intand shall expand to the same value asULONG_WIDTHand be an integer constant expression suitable for use in conditional expression inclusion preprocessing directives.- width for an object of type
unsigned long long intThe macroULLONG_WIDTH 64LLONG_WIDTHrepresents the width of the typelong long intand shall expand to the same value asULLONG_WIDTHand be an integer constant expression suitable for use in conditional expression inclusion preprocessing directives.- maximum width of a bit-precise integer type
The macroBITINT_MAXWIDTH /* see the following */BITINT_MAXWIDTHrepresents the maximum width N supported by the declaration of a bit-precise integer (6.2.5) in the type specifier_BitInt(N). The valueBITINT_MAXWIDTHshall expand to a value that is greater than or equal to the value ofULLONG_WIDTH.- maximum number of bytes in a multibyte character, for any supported locale
MB_LEN_MAX 1For all unsigned integer types for which
<limits.h>or<stdint.h>define a macro with suffix_WIDTHholding its width N, there is a macro with suffix_MAXholding the maximal value 2N − 1 that is representable by the type and that has the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. If the value is in the range of the typeuintmax_t(7.22.2.6) the macro is an integer constant expression suitable for use in conditional expression inclusion preprocessing directives; otherwise, the macro is an integer constant expression that need not be suitable for use in conditional expression inclusion preprocessing directives notwithstanding the provisions of 7.1.4.For all signed integer types for which
<limits.h>or<stdint.h>define a macro with suffix_WIDTHholding its width N, there are macros with suffix_MINand_MAXholding the minimal and maximal values −2N − 1 and 2N − 1 − 1 that are representable by the type and that have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. If the values are in the range of the typeintmax_t(7.22.2.6) the macros are integer constant expressions suitable for use in conditional expression inclusion preprocessing directives; otherwise, the macros are integer constant expressions that need not be suitable for use in conditional expression inclusion preprocessing directives notwithstanding the provisions of 7.1.4.If an object of type
charcan hold negative values, the value ofCHAR_MINshall be the same as that ofSCHAR_MINand the value ofCHAR_MAXshall be the same as that ofSCHAR_MAX. Otherwise, the value ofCHAR_MINshall be 0 and the value ofCHAR_MAXshall be the same as that ofUCHAR_MAX(see 6.2.5.). BothCHAR_MINandCHAR_MAXare integer constant expressions suitable for use in conditional expression inclusion preprocessing directives.
Note: This suggested correction does not interfere with the changes made by N3496, if this correction is incorporated into the working draft the changes should be made in the context of the new wording.