.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved .TH "" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" .\" .SH NAME stdint.h \- integer types .SH SYNOPSIS .LP \fB#include \fP .SH DESCRIPTION .LP 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 IEEE\ Std\ 1003.1-2001, Section 2.2, The Compilation Environment) to enable the visibility of these symbols in this header. .LP The \fI\fP 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. .TP 7 \fBNote:\fP 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 \fIN\fP-bit signed type has values in the range -2**\fIN\fP-1 or 1-2**\fIN\fP-1 to 2**\fIN\fP-1-1, while an \fIN\fP-bit unsigned type has values in the range 0 to 2**\fIN\fP-1. .sp .LP Types are defined in the following categories: .IP " *" 3 Integer types having certain exact widths .LP .IP " *" 3 Integer types having at least certain specified widths .LP .IP " *" 3 Fastest integer types having at least certain specified widths .LP .IP " *" 3 Integer types wide enough to hold pointers to objects .LP .IP " *" 3 Integer types having greatest width .LP .LP (Some of these types may denote the same type.) .LP Corresponding macros specify limits of the declared types and construct suitable constants. .LP For each type described herein that the implementation provides, the \fI\fP header shall declare that \fBtypedef\fP name and define the associated macros. Conversely, for each type described herein that the implementation does not provide, the \fI\fP header shall not declare that \fBtypedef\fP 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). .SS Integer Types .LP When \fBtypedef\fP names differing only in the absence or presence of the initial \fIu\fP 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. .LP In the following descriptions, the symbol \fIN\fP represents an unsigned decimal integer with no leading zeros (for example, 8 or 24, but not 04 or 048). .IP " *" 3 Exact-width integer types .LP The \fBtypedef\fP name \fBint\fP \fIN\fP \fB_t\fP designates a signed integer type with width \fIN\fP, no padding bits, and a two's-complement representation. Thus, \fBint8_t\fP denotes a signed integer type with a width of exactly 8 bits. .LP The \fBtypedef\fP name \fBuint\fP \fIN\fP \fB_t\fP designates an unsigned integer type with width \fIN\fP. Thus, \fBuint24_t\fP denotes an unsigned integer type with a width of exactly 24 bits. .LP The following types are required: .LP .sp \fBint8_t\fP .br \fBint16_t\fP .br \fBint32_t\fP .br \fBuint8_t\fP .br \fBuint16_t\fP .br \fBuint32_t\fP .br .LP If an implementation provides integer types with width 64 that meet these requirements, then the following types are required: \fBint64_t\fP \fBuint64_t\fP .LP In particular, this will be the case if any of the following are true: .RS .IP " *" 3 The implementation supports the _POSIX_V6_ILP32_OFFBIG programming environment and the application is being built in the _POSIX_V6_ILP32_OFFBIG programming environment (see the Shell and Utilities volume of IEEE\ Std\ 1003.1-2001, \fIc99\fP, Programming Environments). .LP .IP " *" 3 The implementation supports the _POSIX_V6_LP64_OFF64 programming environment and the application is being built in the _POSIX_V6_LP64_OFF64 programming environment. .LP .IP " *" 3 The implementation supports the _POSIX_V6_LPBIG_OFFBIG programming environment and the application is being built in the _POSIX_V6_LPBIG_OFFBIG programming environment. .LP .RE .LP All other types of this form are optional. .LP .IP " *" 3 Minimum-width integer types .LP The \fBtypedef\fP name \fBint_least\fP \fIN\fP \fB_t\fP designates a signed integer type with a width of at least \fIN\fP, such that no signed integer type with lesser size has at least the specified width. Thus, \fBint_least32_t\fP denotes a signed integer type with a width of at least 32 bits. .LP The \fBtypedef\fP name \fBuint_least\fP \fIN\fP \fB_t\fP designates an unsigned integer type with a width of at least \fIN\fP, such that no unsigned integer type with lesser size has at least the specified width. Thus, \fBuint_least16_t\fP denotes an unsigned integer type with a width of at least 16 bits. .LP The following types are required: \fBint_least8_t\fP \fBint_least16_t\fP \fBint_least32_t\fP \fBint_least64_t\fP \fBuint_least8_t\fP \fBuint_least16_t\fP \fBuint_least32_t\fP \fBuint_least64_t\fP .LP All other types of this form are optional. .LP .IP " *" 3 Fastest minimum-width integer types .LP 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. .LP 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. .LP The \fBtypedef\fP name \fBint_fast\fP \fIN\fP \fB_t\fP designates the fastest signed integer type with a width of at least \fIN\fP. The \fBtypedef\fP name \fBuint_fast\fP \fIN\fP \fB_t\fP designates the fastest unsigned integer type with a width of at least \fIN\fP. .LP The following types are required: \fBint_fast8_t\fP \fBint_fast16_t\fP \fBint_fast32_t\fP \fBint_fast64_t\fP \fBuint_fast8_t\fP \fBuint_fast16_t\fP \fBuint_fast32_t\fP \fBuint_fast64_t\fP .LP All other types of this form are optional. .LP .IP " *" 3 Integer types capable of holding object pointers .LP The following type designates a signed integer type with the property that any valid pointer to \fBvoid\fP can be converted to this type, then converted back to a pointer to \fBvoid\fP, and the result will compare equal to the original pointer: \fBintptr_t\fP .LP The following type designates an unsigned integer type with the property that any valid pointer to \fBvoid\fP can be converted to this type, then converted back to a pointer to \fBvoid\fP, and the result will compare equal to the original pointer: \fBuintptr_t\fP .LP On XSI-conformant systems, the \fBintptr_t\fP and \fBuintptr_t\fP types are required; \ otherwise, they are optional. .LP .IP " *" 3 Greatest-width integer types .LP The following type designates a signed integer type capable of representing any value of any signed integer type: \fBintmax_t\fP .LP The following type designates an unsigned integer type capable of representing any value of any unsigned integer type: \fBuintmax_t\fP .LP These types are required. .LP .TP 7 \fBNote:\fP Applications can test for optional types by using the corresponding limit macro from Limits of Specified-Width Integer Types . .sp .SS Limits of Specified-Width Integer Types .LP The following macros specify the minimum and maximum limits of the types declared in the \fI\fP header. Each macro name corresponds to a similar type name in Integer Types . .LP Each instance of any defined macro shall be replaced by a constant expression suitable for use in \fB#if\fP 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. .IP " *" 3 Limits of exact-width integer types .RS .IP " *" 3 Minimum values of exact-width signed integer types: .TP 7 {INT\fIN\fP_MIN} .RS Exactly -(2 **N-1) .RE .sp .LP .IP " *" 3 Maximum values of exact-width signed integer types: .TP 7 {INT\fIN\fP_MAX} .RS Exactly 2**N-1 -1 .RE .sp .LP .IP " *" 3 Maximum values of exact-width unsigned integer types: .TP 7 {UINT\fIN\fP_MAX} .RS Exactly 2 **N -1 .RE .sp .LP .RE .LP .IP " *" 3 Limits of minimum-width integer types .RS .IP " *" 3 Minimum values of minimum-width signed integer types: .TP 7 {INT_LEAST\fIN\fP_MIN} .RS -(2 ** N-1 -1) .RE .sp .LP .IP " *" 3 Maximum values of minimum-width signed integer types: .TP 7 {INT_LEAST\fIN\fP_MAX} .RS 2 ** N-1 -1 .RE .sp .LP .IP " *" 3 Maximum values of minimum-width unsigned integer types: .TP 7 {UINT_LEAST\fIN\fP_MAX} .RS 2 ** N -1 .RE .sp .LP .RE .LP .IP " *" 3 Limits of fastest minimum-width integer types .RS .IP " *" 3 Minimum values of fastest minimum-width signed integer types: .TP 7 {INT_FAST\fIN\fP_MIN} .RS -(2 ** N-1 -1) .RE .sp .LP .IP " *" 3 Maximum values of fastest minimum-width signed integer types: .TP 7 {INT_FAST\fIN\fP_MAX} .RS 2 ** N-1 -1 .RE .sp .LP .IP " *" 3 Maximum values of fastest minimum-width unsigned integer types: .TP 7 {UINT_FAST\fIN\fP_MAX} .RS 2 ** N -1 .RE .sp .LP .RE .LP .IP " *" 3 Limits of integer types capable of holding object pointers .RS .IP " *" 3 Minimum value of pointer-holding signed integer type: .TP 7 {INTPTR_MIN} .RS -(2 ** 15 -1) .RE .sp .LP .IP " *" 3 Maximum value of pointer-holding signed integer type: .TP 7 {INTPTR_MAX} .RS 2 ** 15 -1 .RE .sp .LP .IP " *" 3 Maximum value of pointer-holding unsigned integer type: .TP 7 {UINTPTR_MAX} .RS 2 ** 16 -1 .RE .sp .LP .RE .LP .IP " *" 3 Limits of greatest-width integer types .RS .IP " *" 3 Minimum value of greatest-width signed integer type: .TP 7 {INTMAX_MIN} .RS -(2 ** 63 -1) .RE .sp .LP .IP " *" 3 Maximum value of greatest-width signed integer type: .TP 7 {INTMAX_MAX} .RS 2 ** 63 -1 .RE .sp .LP .IP " *" 3 Maximum value of greatest-width unsigned integer type: .TP 7 {UINTMAX_MAX} .RS 2 ** 64 -1 .RE .sp .LP .RE .LP .SS Limits of Other Integer Types .LP The following macros specify the minimum and maximum limits of integer types corresponding to types defined in other standard headers. .LP Each instance of these macros shall be replaced by a constant expression suitable for use in \fB#if\fP 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. .IP " *" 3 Limits of \fBptrdiff_t\fP: .TP 7 {PTRDIFF_MIN} .RS -65535 .RE .TP 7 {PTRDIFF_MAX} .RS +65535 .RE .sp .LP .IP " *" 3 Limits of \fBsig_atomic_t\fP: .TP 7 {SIG_ATOMIC_MIN} .RS See below. .RE .TP 7 {SIG_ATOMIC_MAX} .RS See below. .RE .sp .LP .IP " *" 3 Limit of \fBsize_t\fP: .TP 7 {SIZE_MAX} .RS 65535 .RE .sp .LP .IP " *" 3 Limits of \fBwchar_t\fP: .TP 7 {WCHAR_MIN} .RS See below. .RE .TP 7 {WCHAR_MAX} .RS See below. .RE .sp .LP .IP " *" 3 Limits of \fBwint_t\fP: .TP 7 {WINT_MIN} .RS See below. .RE .TP 7 {WINT_MAX} .RS See below. .RE .sp .LP .LP If \fBsig_atomic_t\fP (see the \fI\fP 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, \fBsig_atomic_t\fP 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. .LP If \fBwchar_t\fP (see the \fI\fP 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, \fBwchar_t\fP 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. .LP If \fBwint_t\fP (see the \fI\fP 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, \fBwint_t\fP 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. .SS Macros for Integer Constant Expressions .LP The following macros expand to integer constant expressions suitable for initializing objects that have integer types corresponding to types defined in the \fI\fP header. Each macro name corresponds to a similar type name listed under \fIMinimum-width integer types\fP and \fIGreatest-width integer types\fP. .LP Each invocation of one of these macros shall expand to an integer constant expression suitable for use in \fB#if\fP 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. .LP The argument in any instance of these macros shall be a decimal, octal, or hexadecimal constant with a value that does not exceed the limits for the corresponding type. .IP " *" 3 Macros for minimum-width integer constant expressions .LP The macro \fIINTN_C\fP( \fIvalue\fP) shall expand to an integer constant expression corresponding to the type \fBint_least\fP \fIN\fP \fB_t\fP. The macro \fIUINTN_C\fP( \fIvalue\fP) shall expand to an integer constant expression corresponding to the type \fBuint_least\fP \fIN\fP \fB_t\fP. For example, if \fBuint_least64_t\fP is a name for the type \fBunsigned long long\fP, then \fIUINT64_C\fP(0x123) might expand to the integer constant 0x123ULL. .LP .IP " *" 3 Macros for greatest-width integer constant expressions .LP The following macro expands to an integer constant expression having the value specified by its argument and the type \fBintmax_t\fP: INTMAX_C(\fIvalue\fP) .LP The following macro expands to an integer constant expression having the value specified by its argument and the type \fBuintmax_t\fP: UINTMAX_C(\fIvalue\fP) .LP .LP \fIThe following sections are informative.\fP .SH APPLICATION USAGE .LP None. .SH RATIONALE .LP The \fI\fP header is a subset of the \fI\fP 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 \fI\fP header avoids defining such a large number of macros. .LP As a consequence of adding \fBint8_t\fP, the following are true: .IP " *" 3 A byte is exactly 8 bits. .LP .IP " *" 3 {CHAR_BIT} has the value 8, {SCHAR_MAX} has the value 127, {SCHAR_MIN} has the value -127 or -128, and {UCHAR_MAX} has the value 255. .LP .SH FUTURE DIRECTIONS .LP \fBtypedef\fP names beginning with \fBint\fP or \fBuint\fP and ending with _t may be added to the types defined in the \fI\fP header. Macro names beginning with INT or UINT and ending with _MAX, _MIN, or _C may be added to the macros defined in the \fI\fP header. .SH SEE ALSO .LP \fI\fP , \fI\fP , \fI\fP , \fI\fP .SH COPYRIGHT Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 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 .