Types
For each of the following typedef names marked (optional), an implementation defines it if and only if the implementation provides a corresponding type.
Defined in header
int8_tint16_tint32_tint64_tintN_t
(optional)(optional)(optional)(optional)(optional)
signed integer type with width of exactly N (typically 8, 16, 32 or 64) bits and no padding bits
(typedef)
int_fast8_tint_fast16_tint_fast32_tint_fast64_tint_fastN_t
(optional)
fastest signed integer type with width of at least N (typically 8, 16, 32 or 64) bits
(typedef)
int_least8_tint_least16_tint_least32_tint_least64_tint_leastN_t
(optional)
smallest signed integer type with width of at least N (typically 8, 16, 32 or 64) bits
(if std::intN_t is defined, std::int_leastN_t designates the same type)
(typedef)
intmax_t
maximum-width signed integer type
(typedef)
intptr_t
(optional until c++29)
signed integer type capable of holding a pointer to void
(typedef)
uint8_tuint16_tuint32_tuint64_tuintN_t
(optional)(optional)(optional)(optional)(optional)
unsigned integer type with width of exactly N (typically 8, 16, 32 or 64) bits and no padding bits
(typedef)
uint_fast8_tuint_fast16_tuint_fast32_tuint_fast64_tuint_fastN_t
(optional)
fastest unsigned integer type with width of at least N (typically 8, 16, 32 or 64) bits
(typedef)
uint_least8_tuint_least16_tuint_least32_tuint_least64_tuint_leastN_t
(optional)
smallest unsigned integer type with width of at least N (typically 8, 16, 32 or 64) bits
(if std::uintN_t is defined, std::uint_leastN_t designates the same type)
(typedef)
uintmax_t
maximum-width unsigned integer type
(typedef)
uintptr_t
(optional until c++29)
unsigned integer type capable of holding a pointer to void
(typedef)
Macro constants
For each of the following macros marked (conditionally present), an implementation defines it if and only if the implementation defines the corresponding typedef name.
Defined in header
Signed integers : bit width INTN_WIDTH
(C++26)(conditionally present)
bit width of std::intN_t (N is typically 8, 16, 32 or 64)
(macro constant)
INT_FASTN_WIDTH
(C++26)(conditionally present)
bit width of std::int_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
INT_LEASTN_WIDTH
(C++26)(conditionally present)
bit width of std::int_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
INTMAX_WIDTH
(C++26)
bit width of std::intmax_t
(macro constant)
INTPTR_WIDTH
(C++26)(conditionally present)
bit width of std::intptr_t
(macro constant)
Signed integers : minimum value INTN_MIN
(conditionally present)
minimum value of std::intN_t (N is typically 8, 16, 32 or 64)
(macro constant)
INT_FASTN_MIN
(conditionally present)
minimum value of std::int_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
INT_LEASTN_MIN
(conditionally present)
minimum value of std::int_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
INTMAX_MIN
minimum value of std::intmax_t
(macro constant)
INTPTR_MIN
(conditionally present)
minimum value of std::intptr_t
(macro constant)
Signed integers : maximum value INTN_MAX
(conditionally present)
maximum value of std::intN_t (N is typically 8, 16, 32 or 64)
(macro constant)
INT_FASTN_MAX
(conditionally present)
maximum value of std::int_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
INT_LEASTN_MAX
(conditionally present)
maximum value of std::int_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
INTMAX_MAX
maximum value of std::intmax_t
(macro constant)
INTPTR_MAX
(conditionally present)
maximum value of std::intptr_t
(macro constant)
Unsigned integers : bit width UINTN_WIDTH
(C++26)(conditionally present)
bit width of std::uintN_t (N is typically 8, 16, 32 or 64)
(macro constant)
UINT_FASTN_WIDTH
(C++26)(conditionally present)
bit width of std::uint_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
UINT_LEASTN_WIDTH
(C++26)(conditionally present)
bit width of std::uint_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
UINTMAX_WIDTH
(C++26)
bit width of std::uintmax_t
(macro constant)
UINTPTR_WIDTH
(C++26)(conditionally present)
bit width of std::uintptr_t
(macro constant)
Unsigned integers : maximum value UINTN_MAX
(conditionally present)
maximum value of std::uintN_t (N is typically 8, 16, 32 or 64)
(macro constant)
UINT_FASTN_MAX
(conditionally present)
maximum value of std::uint_fastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
UINT_LEASTN_MAX
(conditionally present)
maximum value of std::uint_leastN_t (N is typically 8, 16, 32 or 64)
(macro constant)
UINTMAX_MAX
maximum value of std::uintmax_t
(macro constant)
UINTPTR_MAX
(conditionally present)
maximum value of std::uintptr_t
(macro constant)
Function macros
For each of the following macros marked (conditionally present), an implementation defines it if and only if the implementation defines the corresponding typedef name.
INTN_C
(conditionally present)
expands to an integer constant expression of type std::int_leastN_t, its value is specified by the argument
(function macro)
INTMAX_C
expands to an integer constant expression of type std::intmax_t, its value is specified by the argument
(function macro)
UINTN_C
(conditionally present)
expands to an integer constant expression of type std::uint_leastN_t, its value is specified by the argument
(function macro)
UINTMAX_C
expands to an integer constant expression of type std::uintmax_t, its value is specified by the argument
(function macro)
#include<cstdint>UINT64_C(0x123)// expands to a literal of type uint_least64_t and value 0x123Format macro constants
Format constants for the
family of functions
Each of the PRI macros listed here is defined if and only if the implementation defines the corresponding typedef name.
Equivalent
for int or
unsignedintDescription Macros for data types std::intx_t
std::int_leastx_t
std::int_fastx_t
std::intmax_t
std::intptr_t
doutput of a signed decimal integer value PRIdxPRIdLEASTxPRIdFASTxPRIdMAX PRIdPTR iPRIixPRIiLEASTxPRIiFASTxPRIiMAX PRIiPTR uoutput of an unsigned decimal integer value PRIuxPRIuLEASTxPRIuFASTxPRIuMAX PRIuPTR ooutput of an unsigned octal integer value PRIoxPRIoLEASTxPRIoFASTxPRIoMAX PRIoPTR xoutput of an unsigned lowercase hexadecimal integer value PRIxxPRIxLEASTxPRIxFASTxPRIxMAX PRIxPTR Xoutput of an unsigned uppercase hexadecimal integer value PRIXxPRIXLEASTxPRIXFASTxPRIXMAX PRIXPTR Format constants for the
family of functions
Each of the SCN macros listed in here is defined if and only if the implementation defines the corresponding typedef name and has a suitable
length modifier for the type.
Equivalent
for int or
unsignedintDescription Macros for data types std::intx_t
std::int_leastx_t
std::int_fastx_t
std::intmax_t
std::intptr_t
dinput of a signed decimal integer value SCNdxSCNdLEASTxSCNdFASTxSCNdMAX SCNdPTR iinput of a signed integer value SCNixSCNiLEASTxSCNiFASTxSCNiMAX SCNiPTR uinput of an unsigned decimal integer value SCNuxSCNuLEASTxSCNuFASTxSCNuMAX SCNuPTR oinput of an unsigned octal integer value SCNoxSCNoLEASTxSCNoFASTxSCNoMAX SCNoPTR xinput of an unsigned hexadecimal integer value SCNxxSCNxLEASTxSCNxFASTxSCNxMAX SCNxPTR Notes
Because C++ interprets a character immediately following a string literal as a
, C code such as printf("%"PRId64"\n",n); is invalid C++ and requires a space before PRId64.
The C99 standard suggests that C++ implementations should not define the above limit, constant, or format macros unless the macros __STDC_LIMIT_MACROS, __STDC_CONSTANT_MACROS or __STDC_FORMAT_MACROS (respectively) are defined before including the relevant C header (stdint.h or inttypes.h). This recommendation was not adopted by any C++ standard and was removed in C11. However, some implementations (such as glibc 2.17) try to apply this rule, and it may be necessary to define the __STDC macros; C++ compilers may try to work around this by automatically defining them in some circumstances.
std::int8_t may be signedchar and std::uint8_t may be unsignedchar, but neither can be char regardless of its signedness (because char is not considered a "signed integer type" or "unsigned integer type").
Example
See also a
regarding spaces before
used in this example.
Run this code
#include<cinttypes>#include<cstdio>intmain(){std::printf("%zu\n",sizeof(std::int64_t));std::printf("%s\n",PRId64);std::printf("%+"PRId64"\n",INT64_MIN);std::printf("%+"PRId64"\n",INT64_MAX);std::int64_tn=7;std::printf("%+"PRId64"\n",n);}Possible output:
8 lld -9223372036854775808 +9223372036854775807 +7 Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
C++11 the requirements for optional typedef names and macros were inconsistent with C made consistent References
C++23 standard (ISO/IEC 14882:2024):
17.4.1 Header <cstdint> synopsis [cstdint.syn]
31.13.2 Header <cinttypes> synopsis [cinttypes.syn]
C++20 standard (ISO/IEC 14882:2020):
17.4 Integer types [cstdint]
29.12.2 Header <cinttypes> synopsis [cinttypes.syn]
C++17 standard (ISO/IEC 14882:2017):
21.4 Integer types [cstdint]
30.11.2 Header <cinttypes> synopsis [cinttypes.syn]
C++14 standard (ISO/IEC 14882:2014):
18.4 Integer types [cstdint]
27.9.2 C library files [c.files]
C++11 standard (ISO/IEC 14882:2011):
18.4 Integer types [cstdint]
27.9.2 C library files [c.files]
See also