# stdint(7) [freebsd man page]

STDINT(7) BSD Miscellaneous Information Manual STDINT(7)NAME

stdintstandard integer types--SYNOPSIS

#include <stdint.h>DESCRIPTION

The <stdint.h> header provides source-portable integer types of a specific size, smallest memory footprint with a minimum size, fastest access speed with a minimum size, largest integer size, and those capable of storing pointers. The types int8_t, int16_t, int32_t, and int64_t provide a signed integer type of width 8, 16, 32, or 64 bits, respectively. The types uint8_t, uint16_t, uint32_t, and uint64_t provide an unsigned integer type of width 8, 16, 32, or 64 bits, respectively. These integer types should be used when a specific size is required. The types int_fast8_t, int_fast16_t, int_fast32_t, and int_fast64_t provide the fastest signed integer type with a width of at least 8, 16, 32, or 64 bits, respectively. The types uint_fast8_t, uint_fast16_t, uint_fast32_t, and uint_fast64_t provide the fastest unsigned integer type with a width of at least 8, 16, 32, or 64 bits, respectively. These types should be used when access speed is paramount, and when a specific size is not required. The types int_least8_t, int_least16_t, int_least32_t, and int_least64_t provide the smallest memory footprint signed integer type with a width of at least 8, 16, 32, or 64 bits, respectively. The types uint_least8_t, uint_least16_t, uint_least32_t, and uint_least64_t provide the smallest memory footprint unsigned integer type with a width of at least 8, 16, 32, or 64 bits, respectively. These types should be used when memory storage is of concern, and when a specific size is not required. The type intmax_t provides a signed integer type large enough to hold any other signed integer. The type uintmax_t provides an unsigned integer type large enough to hold any other unsigned integer. These types are generally the largest signed and unsigned integer types avail- able on a specific architecture. The type intptr_t provides a signed integer type with the ability to hold a pointer to void, that can later be converted back to a pointer to void. The type uintptr_t provides an unsigned integer type with the ability to hold a pointer to void, that can later be converted back to a pointer to void. Additionally, the <stdint.h> header defines some macros, but none of them are documented here.STANDARDS

The <stdint.h> header conforms to ISO/IEC 9899:1999 (``ISO C99'') and IEEE Std 1003.1-2001 (``POSIX.1'').HISTORY

The <stdint.h> header was first introduced in FreeBSD 5.0.BSD

September 15, 2002 BSD

## Check Out this Related Man Page

stdint.h(3HEAD) Headers stdint.h(3HEAD)NAME

stdint.h, stdint - integer typesSYNOPSIS

#include <stdint.h>DESCRIPTION

The <stdint.h> header declares sets of integer types having specified widths, and defines corresponding sets of macros. It also defines macros that specify limits of integer types corresponding to types defined in other standard headers. The ``width'' of an integer type is the number of bits used to store its value in a pure binary system; the actual type can 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 -2**N-1or 1-2**N-1 to 2**N-1-1, while an N-bit unsigned type has values in the range 0 to 2**N-1. Types are defined in the following categories: o integer types having certain exact widths o integer types having at least certain specified widths o fastest integer types having at least certain specified widths o integer types wide enough to hold pointers to objects o 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 declares that typedef name and defines the associ- ated macros. Conversely, for each type described herein that the implementation does not provide, the <stdint.h> header does not declare that typedef name, nor does it define the associated macros. An implementation provides 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 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 must 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_t designates a signed integer type with width N, no padding bits, and a two's-complement representation. Thus, int8_t denotes a signed integer type with a width of exactly 8 bits. 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. The following types are required: int8_t int16_t int32_t uint8_t uint16_t uint32_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 is the case if any of the following are true: o The implementation supports the _POSIX_V6_ILP32_OFFBIG programming environment and the application is being built in the _POSI X_V6_ILP32_OFFBIG programming environment (see the Shell and Utilities volume of IEEE Std 1003.1-200x, c99, Programming Environ- ments). o The implementation supports the _POSIX_V6_LP64_OFF64 programming environment and the application is being built in the _POSIX_ V6_LP64_OFF64 programming environment. o The implementation supports the _POSIX_V6_LPBIG_OFFBIG programming environment and the application is being built in the _POSIX_V6_LPBIG_OFFBIG programming 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. 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. 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. 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_t designates the fastest signed integer type with a width of at least N. The typedef name uint_fastN_ t des- ignates the fastest unsigned integer type with a width of at least N. 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 intptr_t 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. uintptr_t 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. On standard-conforming systems, the intptr_t and uintptr_t types are required; otherwise, they are optional. Greatest-width integer types intmax_t Designates a signed integer type capable of representing any value of any signed integer type. uintmax_t Designates an unsigned integer type capable of representing any value of any unsigned integer type. These types are required. 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 is replaced by a constant expression suitable for use in #if preprocessing directives. This expression has 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 is 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 o Minimum values of exact-width signed integer types: {INTN_MIN} Exactly -(2**N-1) o Maximum values of exact-width signed integer types: {INTN_MAX} Exactly 2**N-1o Maximum values of exact-width unsigned integer types: {UINTN_MAX} Exactly 2**N-1Limits of minimum-width integer types o Minimum values of minimum-width signed integer types: {INT_LEASTN_MIN} -(2**N-1 -1) o Maximum values of minimum-width signed integer types: {INT_LEASTN_MAX} 2**N-1-1o Maximum values of minimum-width unsigned integer types: {UINT_LEASTN_MAX} 2**N-1Limits of fastest minimum-width integer types o Minimum values of fastest minimum-width signed integer types: {INT_FASTN_MIN} -(2**N-1 -1) o Maximum values of fastest minimum-width signed integer types: {INT_FASTN_MAX} 2**N-1-1o Maximum values of fastest minimum-width unsigned integer types: {UINT_FASTN_MAX} 2**N-1-1Limits of integer types capable of holding object pointers o Minimum value of pointer-holding signed integer type: {INTPTR_MIN} -(2**15 -1) o Maximum value of pointer-holding signed integer type: {INTPTR_MAX} 2**15-1o Minimum value of pointer-holding signed integer type: {UINTPTR_MAX} 2**16-1Limits of greatest-width integer types o Minimum value of greatest-width signed integer type: {INTMAX_MIN} -(2**63 -1) o Maximum value of greatest-width signed integer type: {INTMAX_MIN} 2**63-1o Maximum value of greatest-width unsigned integer type: {UINTMAX_MIN} 2**64-1Limits 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 is replaced by a constant expression suitable for use in #if preprocessing directives. This expression has the same type as would an expression that is an object of the corresponding type converted according to the integer promotions. Its imple- mentation-defined value is equal to or greater in magnitude (absolute value) than the corresponding value given below, with the same sign. Limits of ptrdiff_t: {PTRDIFF_MIN}-1{PTRDIFF_MAX} +65535 Limits of sig_atomic_t: {SIG_ATOMIC_MIN} See below. {SIG_ATOMIC_MAX} See below. Limits 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} is no greater than-65535and the value of {SIG_ATOMIC_MAX} is no less than 127. Otherwise, sig_atomic_t is defined as an unsigned integer type, the value of {SIG_ATOMIC_MIN} is 0, and the value of {SIG_ATOMIC_MAX} is no less than 255. If wchar_t (see the <stddef.h> header) is defined as a signed integer type, the value of {WCHAR_MIN} is no greater than-127and the value of {WCHAR_MAX} is no less than 127. Otherwise, wchar_t is defined as an unsigned integer type, and the value of {WCHAR_MIN} is 0 and the value of {WCHAR_MAX} is no less than 255. If wint_t (see the <wchar.h> header) is defined as a signed integer type, the value of {WINT_MIN} is no greater than-127and the value of {WINT_MAX} is no less than 32767. Otherwise, wint_t is defined as an unsigned integer type, and the value of {WINT_MIN} is 0 and the value of {WINT_MAX} is no less than 65535. 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 expands to an integer constant expression suitable for use in #if preprocessing directives. The type of the expression has 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 is that of the argument. The argument in any instance of these macros is a decimal, octal, or hexa- decimal 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) expands to an integer constant expression corresponding to the type int_leastN_t. The macro UINTN_C(value) expands to an integer constant expression corresponding to the type uint_leastN_t. For example, if uint_least64_t is a name for the type unsigned long long, then UINT64_C(0x123) might expand to the integer constant 0x123ULL. 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)-32767ATTRIBUTES

See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+SEE ALSO

inttypes.h(3HEAD), signal.h(3HEAD), stddef.h(3HEAD), wchar.h(3HEAD), attributes(5), standards(5)SunOS 5.1010 Sep 2004 stdint.h(3HEAD)