stdint.h(0P)
PROLOG ๐
okay bestie, so this manual page is part of the POSIX Programmer's Manual. But real talk: the Linux implementation of this interface may differ (so pls consult the corresponding Linux manual page for the details of Linux behavior), or the interface may not be implemented on Linux at all. ๐
NAME โจ
stdint.h โ integer types. periodt.
SYNOPSIS ๐
#include <stdint.h>
DESCRIPTION ๐ฆ
Some of the functionality described on this reference page extends the ISO C standard. So like, applications shall define the appropriate feature test macro (check the System Interfaces volume of POSIX.1โ2017, Section 2.2, The Compilation Environment) to enable the visibility of these symbols in this header. no cap.
The <stdint.h> header shall declare sets of integer types having specified widths, and it shall define corresponding sets of macros. It shall also define macros that specify limits of integer types corresponding to types defined in other standard headers. it's giving very structured.
Note: The ``width'' of an integer type is the number of bits used to store its value in a pure binary system; the actual type may use more bits than that (for example, a 28-bit type could be stored in 32 bits of actual storage). An N-bit signed type has values in the range -2N-1 or 1-2N-1 to 2N-1-1, while an N-bit unsigned type has values in the range 0 to 2N-1.
Types are defined in the following categories:
- Integer types having certain exact widths
- Integer types having at least certain specified widths
- Fastest integer types having at least certain specified widths
- Integer types wide enough to hold pointers to objects
- Integer types having greatest width
(Some of these types may denote the same type.)
Corresponding macros specify limits of the declared types and construct suitable constants.
For each type described herein that the implementation provides, the <stdint.h> header shall declare that typedef name and define the associated macros. Conversely, for each type described herein that the implementation does not provide, the <stdint.h> header shall not declare that typedef name, nor shall it define the associated macros. An implementation shall provide those types described as required, but it need not provide any of the others (described as optional). like, it's giving conditional.
Integer Types ๐
When typedef names differing only in the absence or presence of the initial u are defined, they shall denote corresponding signed and unsigned types as described in the ISO/IEC 9899:1999 standard, Section 6.2.5; an implementation providing one of these corresponding types shall also provide the other. so like, if you got intN_t, you better have uintN_t too. fr fr.
In the following descriptions, the symbol N represents an unsigned decimal integer with no leading zeros (for example, 8 or 24, but not 04 or 048). no cap.
Exact-width integer types โจ
The typedef name intN_t designates a signed integer type with width N, no padding bits, and a two's-complement representation. So like, int8_t denotes a signed integer type with a width of exactly 8 bits. iconic.
The typedef name uintN_t designates an unsigned integer type with width N. Thus, uint24_t denotes an unsigned integer type with a width of exactly 24 bits. slay.
The following types are required:
int8_tint16_tint32_tuint8_tuint16_tuint32_t
If an implementation provides integer types with width 64 that meet these requirements, then the following types are required: int64_t and uint64_t. periodt.
In particular, this will be the case if any of the following are true:
- The implementation supports the
_POSIX_V7_ILP32_OFFBIGprogramming environment and the application is being built in the_POSIX_V7_ILP32_OFFBIGprogramming environment (see the Shell and Utilities volume of POSIX.1โ2017,c99, Programming Environments). - The implementation supports the
_POSIX_V7_LP64_OFF64programming environment and the application is being built in the_POSIX_V7_LP64_OFF64programming environment. - The implementation supports the
_POSIX_V7_LPBIG_OFFBIGprogramming environment and the application is being built in the_POSIX_V7_LPBIG_OFFBIGprogramming environment.
All other types of this form are optional.
Minimum-width integer types ๐ธ
The typedef name int_leastN_t designates a signed integer type with a width of at least N, such that no signed integer type with lesser size has at least the specified width. Thus, int_least32_t denotes a signed integer type with a width of at least 32 bits. it's giving "at least" energy.
The typedef name uint_leastN_t designates an unsigned integer type with a width of at least N, such that no unsigned integer type with lesser size has at least the specified width. Thus, uint_least16_t denotes an unsigned integer type with a width of at least 16 bits. obsessed.
The following types are required:
int_least8_tint_least16_tint_least32_tint_least64_tuint_least8_tuint_least16_tuint_least32_tuint_least64_t
All other types of this form are optional.
Fastest minimum-width integer types ๐ฅ
Each of the following types designates an integer type that is usually fastest to operate with among all integer types that have at least the specified width. so like, speed demon vibes.
But bestie, the designated type is not guaranteed to be fastest for all purposes; if the implementation has no clear grounds for choosing one type over another, it will simply pick some integer type satisfying the signedness and width requirements. no cap.
The typedef name int_fastN_t designates the fastest signed integer type with a width of at least N. The typedef name uint_fastN_t designates the fastest unsigned integer type with a width of at least N. periodt.
The following types are required:
int_fast8_tint_fast16_tint_fast32_tint_fast64_tuint_fast8_tuint_fast16_tuint_fast32_tuint_fast64_t
All other types of this form are optional.
Integer types capable of holding object pointers ๐
The following type designates a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to a pointer to void, and the result will compare equal to the original pointer: intptr_t. it's giving pointer-holding realness.
The following type designates an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to a pointer to void, and the result will compare equal to the original pointer: uintptr_t. slay.
On XSI-conformant systems, the intptr_t and uintptr_t types are required; otherwise, they are optional. so like, depends on your vibe.
Greatest-width integer types ๐
The following type designates a signed integer type capable of representing any value of any signed integer type: intmax_t. it's giving maximum capacity.
The following type designates an unsigned integer type capable of representing any value of any unsigned integer type: uintmax_t. periodt.
These types are required. no cap.
Note: Applications can test for optional types by using the corresponding limit macro from Limits of Specified-Width Integer Types.
Limits of Specified-Width Integer Types ๐
The following macros specify the minimum and maximum limits of the types declared in the <stdint.h> header. Each macro name corresponds to a similar type name in Integer Types. iykyk.
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. Its implementation-defined value shall be equal to or greater in magnitude (absolute value) than the corresponding value given below, with the same sign, except where stated to be exactly the given value. so like, don't expect exact unless it says exactly.
Limits of exact-width integer types โจ
- Minimum values of exact-width signed integer types:
{INTN_MIN}โ Exactly-(2^N-1)
- Maximum values of exact-width signed integer types:
{INTN_MAX}โ Exactly2^N-1 -1
- Maximum values of exact-width unsigned integer types:
{UINTN_MAX}โ Exactly2^N -1
Limits of minimum-width integer types ๐ธ
- Minimum values of minimum-width signed integer types:
{INT_LEASTN_MIN}โ-(2^N-1 -1)
- Maximum values of minimum-width signed integer types:
{INT_LEASTN_MAX}โ2^N-1 -1
- Maximum values of minimum-width unsigned integer types:
{UINT_LEASTN_MAX}โ2^N -1
Limits of fastest minimum-width integer types ๐ฅ
- Minimum values of fastest minimum-width signed integer types:
{INT_FASTN_MIN}โ-(2^N-1 -1)
- Maximum values of fastest minimum-width signed integer types:
{INT_FASTN_MAX}โ2^N-1 -1
- Maximum values of fastest minimum-width unsigned integer types:
{UINT_FASTN_MAX}โ2^N -1
Limits of integer types capable of holding object pointers ๐
- Minimum value of pointer-holding signed integer type:
{INTPTR_MIN}โ-(2^15 -1)
- Maximum value of pointer-holding signed integer type:
{INTPTR_MAX}โ2^15 -1
- Maximum value of pointer-holding unsigned integer type:
{UINTPTR_MAX}โ2^16 -1
Limits of greatest-width integer types ๐
- Minimum value of greatest-width signed integer type:
{INTMAX_MIN}โ-(2^63 -1)
- Maximum value of greatest-width signed integer type:
{INTMAX_MAX}โ2^63 -1
- Maximum value of greatest-width unsigned integer type:
{UINTMAX_MAX}โ2^64 -1
Limits of Other Integer Types ๐
The following macros specify the minimum and maximum limits of integer types corresponding to types defined in other standard headers. it's giving cross-header energy.
Each instance of these macros 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. Its implementation-defined value shall be equal to or greater in magnitude (absolute value) than the corresponding value given below, with the same sign. no cap.
- Limits of
ptrdiff_t:{PTRDIFF_MIN}โ-65535{PTRDIFF_MAX}โ+65535
- Limits of
sig_atomic_t:{SIG_ATOMIC_MIN}โ See below.{SIG_ATOMIC_MAX}โ See below.
- Limit of
size_t:{SIZE_MAX}โ65535
- Limits of
wchar_t: {WCHAR_MIN}โ See below. ๐{WCHAR_MAX}โ See below. โจ- Limits of
wint_t: ๐{WINT_MIN}โ See below. ๐ธ{WINT_MAX}โ See below. ๐ฆ
Okay so real talk: if sig_atomic_t (peep the <signal.h> header bestie) is defined as a signed integer type, then the value of {SIG_ATOMIC_MIN} shall be no greater than -127 and the value of {SIG_ATOMIC_MAX} shall be no less than 127; otherwise, sig_atomic_t shall be defined as an unsigned integer type, and the value of {SIG_ATOMIC_MIN} shall be 0 and the value of {SIG_ATOMIC_MAX} shall be no less than 255. No cap. ๐
If wchar_t (see the <stddef.h> header) is defined as a signed integer type, the value of {WCHAR_MIN} shall be no greater than -127 and the value of {WCHAR_MAX} shall be no less than 127; otherwise, wchar_t shall be defined as an unsigned integer type, and the value of {WCHAR_MIN} shall be 0 and the value of {WCHAR_MAX} shall be no less than 255. Slay. โจ
If wint_t (see the <wchar.h> header) is defined as a signed integer type, the value of {WINT_MIN} shall be no greater than -32767 and the value of {WINT_MAX} shall be no less than 32767; otherwise, wint_t shall be defined as an unsigned integer type, and the value of {WINT_MIN} shall be 0 and the value of {WINT_MAX} shall be no less than 65535. Periodt. ๐
โจ Macros for Integer Constant Expressions โจ
The following macros expand to integer constant expressions suitable for initializing objects that have integer types corresponding to types defined in the <stdint.h> header. Each macro name corresponds to a similar type name listed under Minimum-width integer types and Greatest-width integer types. ๐
Each invocation of one of these macros shall expand to an integer constant expression suitable for use in #if preprocessing directives. The type of the expression shall have the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. The value of the expression shall be that of the argument. ๐
The argument in any instance of these macros shall be an unsuffixed integer constant with a value that does not exceed the limits for the corresponding type. ๐จ
- Macros for minimum-width integer constant expressions ๐ธ The macro
INTN_C(value)shall expand to an integer constant expression corresponding to the typeint_leastN_t. The macroUINTN_C(value)shall expand to an integer constant expression corresponding to the typeuint_leastN_t. For example, ifuint_least64_tis a name for the typeunsigned long long, thenUINT64_C(0x123)might expand to the integer constant0x123ULL. ๐ - Macros for greatest-width integer constant expressions ๐ฆ The following macro expands to an integer constant expression having the value specified by its argument and the type
intmax_t:INTMAX_C(value)
The following macro expands to an integer constant expression having the value specified by its argument and the type uintmax_t: UINTMAX_C(value)
The following sections are informative. โจ
๐ APPLICATION USAGE ๐
None. ๐
๐ญ RATIONALE ๐ญ
The <stdint.h> header is a subset of the <inttypes.h> header more suitable for use in freestanding environments, which might not support the formatted I/O functions. In some environments, if the formatted conversion support is not wanted, using this header instead of the <inttypes.h> header avoids defining such a large number of macros. ๐ง
As a consequence of adding int8_t, the following are true:
- A byte is exactly
8bits. โญ {CHAR_BIT}has the value8,{SCHAR_MAX}has the value127,{SCHAR_MIN}has the value-128, and{UCHAR_MAX}has the value255. ๐
(The POSIX standard explicitly requires 8-bit char and two's-complement arithmetic.) ๐ฅ
๐ฎ FUTURE DIRECTIONS ๐ฎ
typedef names beginning with int or uint and ending with _t may be added to the types defined in the <stdint.h> header. Macro names beginning with INT or UINT and ending with _MAX, _MIN, or _C may be added to the macros defined in the <stdint.h> header. ๐
๐ SEE ALSO ๐
<inttypes.h><signal.h><stddef.h><wchar.h>
The System Interfaces volume of POSIX.1โ2017, Section 2.2, The Compilation Environment. ๐
๐ COPYRIGHT ๐
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . ๐
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . ๐
This iconic page was served to you by IEEE/The Open Group, 2017, stdint.h(0P) โ stay slaying bestie ๐
โจ
๐ฆ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms