[Previous] [Contents] [Next]

<stdint.h>

[added with C99]


int8_t · int16_t · int32_t · int64_t · int_fast8_t · int_fast16_t · int_fast32_t · int_fast64_t · int_least8_t · int_least16_t · int_least32_t · int_least64_t

uint8_t · uint16_t · uint32_t · uint64_t · uint_fast8_t · uint_fast16_t · uint_fast32_t · uint_fast64_t · uint_least8_t · uint_least16_t · uint_least32_t · uint_least64_t

intmax_t · intptr_t · uintmax_t · uintptr_t

INT8_C · INT16_C · INT32_C · INT64_C · INT8_MAX · INT16_MAX · INT32_MAX · INT64_MAX · INT8_MIN · INT16_MIN · INT32_MIN · INT64_MIN · INT_FAST8_MAX · INT_FAST16_MAX · INT_FAST32_MAX · INT_FAST64_MAX · INT_FAST8_MIN · INT_FAST16_MIN · INT_FAST32_MIN · INT_FAST64_MIN · INT_LEAST8_MAX · INT_LEAST16_MAX · INT_LEAST32_MAX · INT_LEAST64_MAX · INT_LEAST8_MIN · INT_LEAST16_MIN · INT_LEAST32_MIN · INT_LEAST64_MIN

UINT8_C · UINT16_C · UINT32_C · UINT64_C · UINTMAX_C · UINT8_MAX · UINT16_MAX · UINT32_MAX · UINT64_MAX · UINT_FAST8_MAX · UINT_FAST16_MAX · UINT_FAST32_MAX · UINT_FAST64_MAX · UINT_LEAST8_MAX · UINT_LEAST16_MAX · UINT_LEAST32_MAX · UINT_LEAST64_MAX

INTMAX_C · INTMAX_MAX · INTMAX_MIN · INTPTR_MAX · INTPTR_MIN · PTRDIFF_MAX · PTRDIFF_MIN · SIG_ATOMIC_MAX · SIG_ATOMIC_MIN · SIZE_MAX · WCHAR_MAX · WCHAR_MIN · WINT_MAX · WINT_MIN · UINTMAX_MAX · UINTPTR_MAX


Include the standard header <stdint.h> to define various integer types, and related macros, with size constraints. Note that the definitions shown for the types and macros are merely representative -- they can vary among implementations.

        /* TYPE DEFINITIONS */
typedef signed char int8_t;
typedef short int16_t;
typedef long int32_t;
typedef long long int64_t;

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
typedef unsigned long long uint64_t;

typedef signed char int_least8_t;
typedef short int_least16_t;
typedef long int_least32_t;
typedef long long int_least64_t;

typedef unsigned char uint_least8_t;
typedef unsigned short uint_least16_t;
typedef unsigned long uint_least32_t;
typedef unsigned long long uint_least64_t;

typedef signed char int_fast8_t;
typedef short int_fast16_t;
typedef long int_fast32_t;
typedef long long int_fast64_t;

typedef unsigned char uint_fast8_t;
typedef unsigned short uint_fast16_t;
typedef unsigned long uint_fast32_t;
typedef unsigned long long uint_fast64_t;

typedef long intptr_t;
typedef unsigned long uintptr_t;

typedef long long intmax_t;
typedef unsigned long long uintmax_t;

        /* LIMIT MACROS */
#define INT8_MIN    (-0x7f - 1)
#define INT16_MIN   (-0x7fff - 1)
#define INT32_MIN   (-0x7fffffff - 1)
#define INT64_MIN   (-0x7fffffffffffffff - 1)

#define INT8_MAX    0x7f [exact]
#define INT16_MAX   0x7fff [exact]
#define INT32_MAX   0x7fffffff [exact]
#define INT64_MAX   0x7fffffffffffffff [exact]

#define UINT8_MAX   0xff [exact]
#define UINT16_MAX  0xffff [exact]
#define UINT32_MAX  0xffffffff [exact]
#define UINT64_MAX  0xffffffffffffffff [exact]

#define INT_LEAST8_MIN    (-0x7f - 1)
#define INT_LEAST16_MIN   (-0x7fff - 1)
#define INT_LEAST32_MIN   (-0x7fffffff - 1)
#define INT_LEAST64_MIN   (-0x7fffffffffffffff - 1)

#define INT_LEAST8_MAX    0x7f
#define INT_LEAST16_MAX   0x7fff
#define INT_LEAST32_MAX   0x7fffffff
#define INT_LEAST64_MAX   0x7fffffffffffffff

#define UINT_LEAST8_MAX   0xff
#define UINT_LEAST16_MAX  0xffff
#define UINT_LEAST32_MAX  0xffffffff
#define UINT_LEAST64_MAX  0xffffffffffffffff

#define INT_FAST8_MIN     (-0x7f - 1)
#define INT_FAST16_MIN    (-0x7fff - 1)
#define INT_FAST32_MIN    (-0x7fffffff - 1)
#define INT_FAST64_MIN    (-0x7fffffffffffffff - 1)

#define INT_FAST8_MAX     0x7f
#define INT_FAST16_MAX    0x7fff
#define INT_FAST32_MAX    0x7fffffff
#define INT_FAST64_MAX    0x7fffffffffffffff

#define UINT_FAST8_MAX    0xff
#define UINT_FAST16_MAX   0xffff
#define UINT_FAST32_MAX   0xffffffff
#define UINT_FAST64_MAX   0xffffffffffffffff

#define INTPTR_MIN        (-0x7fffffff - 1)
#define INTPTR_MAX        0x7fffffff
#define UINTPTR_MAX       0xffffffff

#define INT8_C(x)    (x)
#define INT16_C(x)   (x)
#define INT32_C(x)   ((x) + (INT32_MAX - INT32_MAX))
#define INT64_C(x)   ((x) + (INT64_MAX - INT64_MAX))

#define UINT8_C(x)   (x)
#define UINT16_C(x)  (x)
#define UINT32_C(x)  ((x) + (UINT32_MAX - UINT32_MAX))
#define UINT64_C(x)  ((x) + (UINT64_MAX - UINT64_MAX))

#define INTMAX_C(x)  ((x) + (INT64_MAX - INT64_MAX))
#define UINTMAX_C(x) ((x) + (UINT64_MAX - UINT64_MAX))

#define PTRDIFF_MIN  INT32_MIN
#define PTRDIFF_MAX  INT32_MAX

#define SIG_ATOMIC_MIN    INT32_MIN
#define SIG_ATOMIC_MAX    INT32_MAX

#define SIZE_MAX     UINT32_MAX

#define WCHAR_MIN    0
#define WCHAR_MAX    UINT16_MAX

#define WINT_MIN     0
#define WINT_MAX     UINT16_MAX

#define INTMAX_MIN        (-0x7fffffffffffffff - 1)
#define INTMAX_MAX        0x7fffffffffffffff
#define UINTMAX_MAX       0xffffffffffffffff

INT8_C, INT16_C, INT32_C, INT64_C

#define INT8_C(x)    (x)
#define INT16_C(x)   (x)
#define INT32_C(x)   ((x) + (INT32_MAX - INT32_MAX))
#define INT64_C(x)   ((x) + (INT64_MAX - INT64_MAX))

The macros each convert an integer literal to a signed integer type whose representation has at least eight, 16, 32, or 64 bits, respectively. Note that the definitions shown here are merely representative.

INT8_MAX, INT16_MAX, INT32_MAX, INT64_MAX

#define INT8_MAX    0x7f [exact]
#define INT16_MAX   0x7fff [exact]
#define INT32_MAX   0x7fffffff [exact]
#define INT64_MAX   0x7fffffffffffffff [exact]

The macros each expand to an #if expression that yields the maximum value representable as type int8_t, int16_t, int32_t, or int64_t, respectively. Note that the definitions shown here are exact.

INT8_MIN, INT16_MIN, INT32_MIN, INT64_MIN

#define INT8_MIN    (-0x7f - 1)
#define INT16_MIN   (-0x7fff - 1)
#define INT32_MIN   (-0x7fffffff - 1)
#define INT64_MIN   (-0x7fffffffffffffff - 1)

The macros each expand to an #if expression that yields the minimum value representable as type int8_t, int16_t, int32_t, or int64_t, respectively. Note that the definitions shown here are merely representative.

int8_t, int16_t, int32_t, int64_t

typedef signed char int8_t;
typedef short int16_t;
typedef long int32_t;
typedef long long int64_t;

The types each specify a signed integer type whose representation has exactly eight, 16, 32, or 64 bits, respectively. Note that the definitions shown here are merely representative.

INT_FAST8_MAX, INT_FAST16_MAX, INT_FAST32_MAX, INT_FAST64_MAX

#define INT_FAST8_MAX     0x7f
#define INT_FAST16_MAX    0x7fff
#define INT_FAST32_MAX    0x7fffffff
#define INT_FAST64_MAX    0x7fffffffffffffff

The macros each expand to an #if expression that yields the maximum value representable as type int_fast8_t, int_fast16_t, int_fast32_t, or int_fast64_t, respectively. Note that the definitions shown here are merely representative.

INT_FAST8_MIN, INT_FAST16_MIN, INT_FAST32_MIN, INT_FAST64_MIN

#define INT_FAST8_MIN     (-0x7f - 1)
#define INT_FAST16_MIN    (-0x7fff - 1)
#define INT_FAST32_MIN    (-0x7fffffff - 1)
#define INT_FAST64_MIN    (-0x7fffffffffffffff - 1)

The macros each expand to an #if expression that yields the minimum value representable as type int_fast8_t, int_fast16_t, int_fast32_t, or int_fast64_t, respectively. Note that the definitions shown here are merely representative.

int_fast8_t, int_fast16_t, int_fast32_t, int_fast64_t

typedef signed char int_fast8_t;
typedef short int_fast16_t;
typedef long int_fast32_t;
typedef long long int_fast64_t;

The types each specify a signed integer type that supports the fastest operations among those whose representation has at least eight, 16, 32, or 64 bits, respectively. Note that the definitions shown here are merely representative.

INT_LEAST8_MAX, INT_LEAST16_MAX, INT_LEAST32_MAX, INT_LEAST64_MAX

#define INT_LEAST8_MAX    0x7f
#define INT_LEAST16_MAX   0x7fff
#define INT_LEAST32_MAX   0x7fffffff
#define INT_LEAST64_MAX   0x7fffffffffffffff

The macros each expand to an #if expression that yields the maximum value representable as type int_least8_t, int_least16_t, int_least32_t, or int_least64_t, respectively. Note that the definitions shown here are merely representative.

INT_LEAST8_MIN, INT_LEAST16_MIN, INT_LEAST32_MIN, INT_LEAST64_MIN

#define INT_LEAST8_MIN    (-0x7f - 1)
#define INT_LEAST16_MIN   (-0x7fff - 1)
#define INT_LEAST32_MIN   (-0x7fffffff - 1)
#define INT_LEAST64_MIN   (-0x7fffffffffffffff - 1)

The macros each expand to an #if expression that yields the minimum value representable as type int_least8_t, int_least16_t, int_least32_t, or int_least64_t, respectively. Note that the definitions shown here are merely representative.

int_least8_t, int_least16_t, int_least32_t, int_least64_t

typedef signed char int_least8_t;
typedef short int_least16_t;
typedef long int_least32_t;
typedef long long int_least64_t;

The types each specify a signed integer type whose representation has at least eight, 16, 32, or 64 bits, respectively. Note that the definitions shown here are merely representative.

INTMAX_C

#define INTMAX_C(x)  ((x) + (INT64_MAX - INT64_MAX))

The macro converts an integer literal to the largest signed integer type. Note that the definition shown here is merely representative.

INTMAX_MAX

#define INTMAX_MAX        0x7fffffffffffffff

The macro expands to an #if expression that yields the maximum value representable as type intmax_t. Note that the definition shown here is merely representative.

INTMAX_MIN

#define INTMAX_MIN        (-0x7fffffffffffffff - 1)

The macro expands to an #if expression that yields the minimum value representable as type intmax_t. Note that the definition shown here is merely representative.

intmax_t

typedef long long intmax_t;

The type specifies the largest signed integer type. Note that the definition shown here is merely representative.

INTPTR_MAX

#define INTPTR_MAX        0x7fffffff

The macro expands to an #if expression that yields the maximum value representable as type intptr_t. Note that the definition shown here is merely representative.

INTPTR_MIN

#define INTPTR_MIN        (-0x7fffffff - 1)

The macro expands to an #if expression that yields the minimum value representable as type intptr_t. Note that the definition shown here is merely representative.

intptr_t

typedef long intptr_t;

The type specifies a signed integer type large enough to support interconversion with a void pointer. (You can convert a void pointer to intptr_t and back, and the result compares equal to the original pointer value.) Note that the definition shown here is merely representative.

PTRDIFF_MAX

#define PTRDIFF_MAX  INT32_MAX

The macro expands to an #if expression that yields the maximum value representable as type ptrdiff_t. Note that the definition shown here is merely representative.

PTRDIFF_MIN

#define PTRDIFF_MIN  INT32_MIN

The macro expands to an #if expression that yields the minimum value representable as type ptrdiff_t. Note that the definition shown here is merely representative.

SIG_ATOMIC_MAX

#define SIG_ATOMIC_MAX    INT32_MAX

The macro expands to an #if expression that yields the maximum value representable as type sig_atomic_t. Note that the definition shown here is merely representative.

SIG_ATOMIC_MIN

#define SIG_ATOMIC_MIN    INT32_MIN

The macro expands to an #if expression that yields the minimum value representable as type sig_atomic_t. Note that the definition shown here is merely representative.

SIZE_MAX

#define SIZE_MAX     UINT32_MAX

The macro expands to an #if expression that yields the maximum value representable as type size_t. Note that the definition shown here is merely representative.

UINT8_C, UINT16_C, UINT32_C, UINT64_C

#define UINT8_C(x)   (x)
#define UINT16_C(x)  (x)
#define UINT32_C(x)  ((x) + (UINT32_MAX - UINT32_MAX))
#define UINT64_C(x)  ((x) + (UINT64_MAX - UINT64_MAX))

The macros each convert an integer literal to an unsigned integer type whose representation has at least eight, 16, 32, or 64 bits, respectively. Note that the definitions shown here are merely representative.

UINT8_MAX, UINT16_MAX, UINT32_MAX, UINT64_MAX

#define UINT8_MAX   0xff [exact]
#define UINT16_MAX  0xffff [exact]
#define UINT32_MAX  0xffffffff [exact]
#define UINT64_MAX  0xffffffffffffffff [exact]

The macros each expand to an #if expression that yields the maximum value representable as type uint8_t, uint16_t, uint32_t, or uint64_t, respectively. Note that the definitions shown here are exact.

uint8_t, uint16_t, uint32_t, uint64_t

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;
typedef unsigned long long uint64_t;

The types each specify an unsigned integer type whose representation has exactly eight, 16, 32, or 64 bits, respectively. Note that the definitions shown here are merely representative.

UINT_FAST8_MAX, UINT_FAST16_MAX, UINT_FAST32_MAX, UINT_FAST64_MAX

#define UINT_FAST8_MAX    0xff
#define UINT_FAST16_MAX   0xffff
#define UINT_FAST32_MAX   0xffffffff
#define UINT_FAST64_MAX   0xffffffffffffffff

The macros each expand to an #if expression that yields the maximum value representable as type uint_fast8_t, uint_fast16_t, uint_fast32_t, or uint_fast64_t, respectively. Note that the definitions shown here are merely representative

uint_fast8_t, uint_fast16_t, uint_fast32_t, uint_fast64_t

typedef unsigned char uint_fast8_t;
typedef unsigned short uint_fast16_t;
typedef unsigned long uint_fast32_t;
typedef unsigned long long uint_fast64_t;

The types each specify an unsigned integer type that supports the fastest operations among those whose representation has at least eight, 16, 32, or 64 bits, respectively. Note that the definitions shown here are merely representative.

UINT_LEAST8_MAX, UINT_LEAST16_MAX, UINT_LEAST32_MAX, UINT_LEAST64_MAX

#define UINT_LEAST8_MAX   0xff
#define UINT_LEAST16_MAX  0xffff
#define UINT_LEAST32_MAX  0xffffffff
#define UINT_LEAST64_MAX  0xffffffffffffffff

The macros each expand to an #if expression that yields the maximum value representable as type uint_least8_t, uint_least16_t, uint_least32_t, or uint_least64_t, respectively. Note that the definitions shown here are merely representative

uint_least8_t, uint_least16_t, uint_least32_t, uint_least64_t

typedef unsigned char uint_least8_t;
typedef unsigned short uint_least16_t;
typedef unsigned long uint_least32_t;
typedef unsigned long long uint_least64_t;

The types each specify an unsigned integer type whose representation has at least eight, 16, 32, or 64 bits, respectively. Note that the definitions shown here are merely representative.

UINTMAX_C

#define UINTMAX_C(x) ((x) + (UINT64_MAX - UINT64_MAX))

The macro converts an unsuffixed integer literal to the largest unsigned integer type. Note that the definition shown here is merely representative.

UINTMAX_MAX

#define UINTMAX_MAX       0xffffffffffffffff

The macro expands to an #if expression that yields the maximum value representable as type uintmax_t. Note that the definition shown here is merely representative.

uintmax_t

typedef unsigned long long uintmax_t;

The type specifies the largest unsigned integer type. Note that the definition shown here is merely representative.

UINTPTR_MAX

#define UINTPTR_MAX       0xffffffff

The macro expands to an #if expression that yields the maximum value representable as type uintptr_t. Note that the definition shown here is merely representative.

uintptr_t

typedef unsigned long uintptr_t;

The type specifies an unsigned integer type large enough to support interconversion with a void pointer. (You can convert a void pointer to uintptr_t and back, and the result compares equal to the original pointer value.) Note that the definition shown here is merely representative.

WCHAR_MAX

#define WCHAR_MAX    UINT16_MAX

The macro expands to an #if expression that yields the maximum value representable as type wchar_t. Note that the definition shown here is merely representative.

WCHAR_MIN

#define WCHAR_MIN    0

The macro expands to an #if expression that yields the minimum value representable as type wchar_t. Note that the definition shown here is merely representative.

WINT_MAX

#define WINT_MAX     UINT16_MAX

The macro expands to an #if expression that yields the maximum value representable as type wint_t. Note that the definition shown here is merely representative.

WINT_MIN

#define WINT_MIN     0

The macro expands to an #if expression that yields the minimum value representable as type wint_t. Note that the definition shown here is merely representative.

Copyright © 1992-2006 by P.J. Plauger. All rights reserved.

[Previous] [Contents] [Next]