stdint.h(7POSIX)
๐ stdint.h(7POSIX) ๐
โจ PROLOG โจ
Okay bestie, real talk: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. So like, check your local page before you @ me ๐ .
๐ธ NAME ๐ธ
stdint.h โ integer types ๐
๐ฆ SYNOPSIS ๐ฆ
#include <stdint.h>
๐ DESCRIPTION ๐
Some of the functionality described on this reference page extends the ISO C standard. Applications shall define the appropriate feature test macro (see the System Interfaces volume of POSIX.1โ2017, Section 2.2, The Compilation Environment) to enable the visibility of these symbols in this header. Slay.
The <stdint.h> header shall declare sets of integer types having specified widths, and 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.
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-1or1-2N-1to2N-1-1, while an N-bit unsigned type has values in the range0to2N-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 need not provide any of the others (described as optional).
๐ 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.
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).
- Exact-width integer types
- The typedef name
intN_tdesignates a signed integer type with widthN, no padding bits, and a two's-complement representation. Thus,int8_tdenotes a signed integer type with a width of exactly 8 bits. - The typedef name
uintN_tdesignates an unsigned integer type with widthN. Thus,uint24_tdenotes an unsigned integer type with a width of exactly 24 bits. - 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,uint64_t. - 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.
- The implementation supports the
- All other types of this form are optional.
- The typedef name
- Minimum-width integer types
- The typedef name
int_leastN_tdesignates a signed integer type with a width of at leastN, such that no signed integer type with lesser size has at least the specified width. Thus,int_least32_tdenotes a signed integer type with a width of at least 32 bits. - The typedef name
uint_leastN_tdesignates an unsigned integer type with a width of at leastN, such that no unsigned integer type with lesser size has at least the specified width. Thus,uint_least16_tdenotes an unsigned integer type with a width of at least 16 bits. - The following types are required:
int_least8_t,int_least16_t,int_least32_t,int_least64_t,uint_least8_t,uint_least16_t,uint_least32_t,uint_least64_t. - All other types of this form are optional.
- The typedef name
- 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.
- 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.
- The typedef name
int_fastN_tdesignates the fastest signed integer type with a width of at leastN. The typedef nameuint_fastN_tdesignates the fastest unsigned integer type with a width of at leastN. - The following types are required:
int_fast8_t,int_fast16_t,int_fast32_t,int_fast64_t,uint_fast8_t,uint_fast16_t,uint_fast32_t,uint_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
voidcan be converted to this type, then converted back to a pointer tovoid, and the result will compare equal to the original pointer:intptr_t. - The following type designates an unsigned integer type with the property that any valid pointer to
voidcan be converted to this type, then converted back to a pointer tovoid, and the result will compare equal to the original pointer:uintptr_t. - On XSI-conformant systems, the
intptr_tanduintptr_ttypes are required; otherwise, they are optional.
- The following type designates a signed integer type with the property that any valid pointer to
- Greatest-width integer types
- The following type designates a signed integer type capable of representing any value of any signed integer type:
intmax_t. - The following type designates an unsigned integer type capable of representing any value of any unsigned integer type:
uintmax_t. - These types are required.
- The following type designates a signed integer type capable of representing any value of any signed integer type:
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.
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.
- 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
- Minimum values of exact-width signed integer types:
- 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
- Minimum values of minimum-width signed integer types:
- 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
- Minimum values of fastest minimum-width signed integer types:
- 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
- Minimum value of pointer-holding signed integer type:
- 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
- Minimum value of greatest-width signed integer type:
๐ 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.
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.
- 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. ๐
If sig_atomic_t (see the <signal.h> header) is defined as a signed integer type, 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. It's giving "signed or unsigned, pick your vibe." ๐
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. Same energy, different type. โจ
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. Bigger numbers, same drama. ๐
## 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. (iykyk ๐)
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. (No cap, fr fr.)
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. Periodt. ๐
- The macro
- 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 macro expands to an integer constant expression having the value specified by its argument and the type
The following sections are informative. (So like, take them as a vibe, not a rulebook. ๐)
APPLICATION USAGE ๐ ๏ธ
None. (Literally none. Not a single crumb. ๐)
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 8 bits. (Yes, exactly. No more, no less. โก)
{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.) The way that's non-negotiable. ๐
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. (So keep an eye out, bestie. ๐)
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 .
Stay iconic, bestie ๐
โจ โ IEEE/The Open Group, 2017, stdint.h(7POSIX)
๐ฆ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 ยท Other
- debian trixie: manpages-posix-dev 2017a-2 ยท Other
- ubuntu jammy: manpages-posix-dev 2017a-2 ยท Other
- ubuntu noble: manpages-posix-dev 2017a-2 ยท Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms