CKTIS / C
Integer constant macros
Macros from <stdint.h> produce portable integer constant expressions without manually selecting suffixes. Their numbered variants correspond to minimum-width types, not necessarily exact-width types.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <stdint.h>
INTMAX_C(value), UINTMAX_C(value)
INT8_C(value), UINT8_C(value)
INT16_C(value), UINT16_C(value)
INT32_C(value), UINT32_C(value)
INT64_C(value), UINT64_C(value)Function-like macros from <stdint.h> produce integer constant expressions rather than performing runtime casts. INTMAX_C corresponds to intmax_t, and UINTMAX_C to uintmax_t.
The pairs INT8_C/UINT8_C, INT16_C/UINT16_C, INT32_C/UINT32_C, and INT64_C/UINT64_C correspond to int_leastN_t/uint_leastN_t for N equal to 8, 16, 32, and 64 respectively. They do not guarantee exactly that many bits. The expression type accounts for integer promotions: even UINT8_C(1) can have type int.
The argument must be an unsuffixed integer constant within the corresponding type's range; do not supply a variable, 1 + 2, or 42U. For a negative value, write -INT64_C(42), not INT64_C(-42). Do not assume a particular expansion, such as a suffix of ULL.
Examples
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
int main(void)
{
int_least64_t delta = -INT64_C(42);
uint_least64_t count = UINT64_C(5000000000);
intmax_t signed_value = INTMAX_C(123);
uintmax_t unsigned_value = UINTMAX_C(456);
printf("%" PRIdMAX " %" PRIuMAX " %" PRIdMAX " %" PRIuMAX "\n",
(intmax_t)delta, (uintmax_t)count,
signed_value, unsigned_value);
return 0;
}Result
-42 5000000000 123 456
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.