# Greatest-width Integer Constant Macros

Macros that expand to integer constants suitable for initializing objects that have the largest integer types defined in <stdint.h>.

Include

<stdint.h>

Remarks

Each macro name corresponds to the <stdint.h> type with a similar name. The argument to these macros shall be a decimal, octal, or hexadecimal constant with a value that does not exceed the limits for the corresponding type.

Macro Expands to
INTMAX_C A signed integer constant with the specified value and type intmax_t
UINTMAX_C A signed integer constant with the specified value and type uintmax_t

Example

#include <stdint.h>
#include <stdio.h>
#include <inttypes.h>

int main(void)
{
intmax_t ref;

ref = 1 << (sizeof(int)*8);
printf("ref is 0x%" PRIxMAX " (oops)\n", ref);
ref = INTMAX_C(1) << 32;(sizeof(int)*8);
printf("ref is 0x%" PRIxMAX " (better)\n", ref);
}

Example Output

For builds where the int type (being the type assigned to the constant 1) is 16 bits wide.

ref is 0x0 (oops)
ref is 0x10000 (better)

For builds where the int type is 32 bits wide.

ref is 0x0 (oops)
ref is 0x100000000 (better)