On 2026-02-17 David Grayson wrote:
> What type scheme should we use in our headers going forward? Should
> the macro's type match its name or should we let the compiler
> implicitly change the smaller-value macros to int?
The C standards require that the macros have promoted types. From C11
7.20.2p2:
Each instance of any defined macro shall be replaced by a constant
expression suitable for use in #if preprocessing directives, and
this expression shall have the same type as would an expression
that is an object of the corresponding type converted according to
the integer promotions.
C99 7.18.2p2 has the same text. C23 has different wording, but it
doesn't change the meaning. See C23 7.22.5 and 5.2.4.2.1p2 and p3.
Thus, mingw-w64's stdint.h is already correct, including UINT8_MAX and
UINT16_MAX which correctly don't have the U suffix:
#define UINT8_MAX 255
#define UINT16_MAX 65535
#define UINT32_MAX 0xffffffffU /* 4294967295U */
#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
However, in limits.h, USHRT_MAX looks wrong because it shouldn't have
the U suffix when int is 32 bits:
#define USHRT_MAX 0xffffU
--
Lasse Collin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public