.\" .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for .\" permission to reproduce portions of its copyrighted documentation. .\" Original documentation from The Open Group can be obtained online at .\" http://www.opengroup.org/bookstore/. .\" .\" The Institute of Electrical and Electronics Engineers and The Open .\" Group, have given us permission to reprint portions of their .\" documentation. .\" .\" In the following statement, the phrase ``this text'' refers to portions .\" of the system documentation. .\" .\" Portions of this text are reprinted and reproduced in electronic form .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition, .\" Standard for Information Technology -- Portable Operating System .\" Interface (POSIX), The Open Group Base Specifications Issue 6, .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics .\" Engineers, Inc and The Open Group. In the event of any discrepancy .\" between these versions 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. .\" .\" This notice shall appear on any product containing this material. .\" .\" The contents of this file are subject to the terms of the .\" Common Development and Distribution License (the "License"). .\" You may not use this file except in compliance with the License. .\" .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE .\" or http://www.opensolaris.org/os/licensing. .\" See the License for the specific language governing permissions .\" and limitations under the License. .\" .\" When distributing Covered Code, include this CDDL HEADER in each .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. .\" If applicable, add the following below this CDDL HEADER, with the .\" fields enclosed by brackets "[]" replaced with your own identifying .\" information: Portions Copyright [yyyy] [name of copyright owner] .\" .\" .\" Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved. .\" Portions Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved. .\" .TH STDINT.H 3HEAD "Sep 10, 2004" .SH NAME stdint.h, stdint \- integer types .SH SYNOPSIS .LP .nf #include <\fBstdint.h\fR> .fi .SH DESCRIPTION .sp .LP The <\fBstdint.h\fR> 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. .sp .LP 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-1 or 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. .sp .LP Types are defined in the following categories: .RS +4 .TP .ie t \(bu .el o integer types having certain exact widths .RE .RS +4 .TP .ie t \(bu .el o integer types having at least certain specified widths .RE .RS +4 .TP .ie t \(bu .el o fastest integer types having at least certain specified widths .RE .RS +4 .TP .ie t \(bu .el o integer types wide enough to hold pointers to objects .RE .RS +4 .TP .ie t \(bu .el o integer types having greatest width .RE .sp .LP Some of these types may denote the same type. .sp .LP Corresponding macros specify limits of the declared types and construct suitable constants. .sp .LP For each type described herein that the implementation provides, the <\fBstdint.h\fR> header declares that \fBtypedef\fR name and defines the associated macros. Conversely, for each type described herein that the implementation does not provide, the <\fBstdint.h\fR> header does not declare that \fBtypedef\fR 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). .SS "Integer Types" .sp .LP When \fBtypedef\fR names differing only in the absence or presence of the initial \fBu\fR 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. .sp .LP In the following descriptions, the symbol \fIN\fR represents an unsigned decimal integer with no leading zeros (for example, 8 or 24, but not 04 or 048). .sp .ne 2 .na \fBExact-width integer types\fR .ad .sp .6 .RS 4n The \fBtypedef\fR name \fBint\fIN\fR_t\fR designates a signed integer type with width \fIN\fR, no padding bits, and a two's-complement representation. Thus, \fBint8_t\fR denotes a signed integer type with a width of exactly 8 bits. .sp The typedef name \fBuint\fIN\fR_t\fR designates an unsigned integer type with width \fIN\fR. Thus, \fBuint24_t\fR denotes an unsigned integer type with a width of exactly 24 bits. .sp The following types are required: .sp .in +2 .nf int8_t int16_t int32_t uint8_t uint16_t uint32_t .fi .in -2 If an implementation provides integer types with width 64 that meet these requirements, then the following types are required: .sp .in +2 .nf int64_t uint64_t .fi .in -2 In particular, this is the case if any of the following are true: .RS +4 .TP .ie t \(bu .el o The implementation supports the \fB_POSIX_V6_ILP32_OFFBIG\fR programming environment and the application is being built in the \fB_POSI X_V6_ILP32_OFFBIG\fR programming environment (see the Shell and Utilities volume of IEEE Std 1003.1-200x, c99, Programming Environments). .RE .RS +4 .TP .ie t \(bu .el o The implementation supports the \fB_POSIX_V6_LP64_OFF64\fR programming environment and the application is being built in the \fB_POSIX_ V6_LP64_OFF64\fR programming environment. .RE .RS +4 .TP .ie t \(bu .el o The implementation supports the \fB_POSIX_V6_LPBIG_OFFBIG\fR programming environment and the application is being built in the \fB_POSIX_V6_LPBIG_OFFBIG\fR programming environment. .RE All other types of this form are optional. .RE .sp .ne 2 .na \fBMinimum-width integer types\fR .ad .sp .6 .RS 4n The \fBtypedef\fR name \fBint_least\fIN\fR_t\fR designates a signed integer type with a width of at least \fIN\fR, such that no signed integer type with lesser size has at least the specified width. Thus, \fBint_least32 _t\fR denotes a signed integer type with a width of at least 32 bits. .sp The \fBtypedef\fR name \fBuint_least\fIN\fR_t\fR designates an unsigned integer type with a width of at least \fIN\fR, such that no unsigned integer type with lesser size has at least the specified width. Thus, \fBuint_ least16_t\fR denotes an unsigned integer type with a width of at least 16 bits. .sp The following types are required: .sp .in +2 .nf int_least8_t int_least16_t int_least32_t int_least64_t uint_least8_t uint_least16_t uint_least32_t uint_least64_t .fi .in -2 All other types of this form are optional. .RE .sp .ne 2 .na \fBFastest minimum-width integer types\fR .ad .sp .6 .RS 4n 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. .sp 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. .sp The \fBtypedef\fR name \fBint_fast\fIN\fR_t\fR designates the fastest signed integer type with a width of at least \fIN\fR. The \fBtypedef\fR name \fBuint_fast\fIN\fR_ t\fR designates the fastest unsigned integer type with a width of at least \fIN\fR. .sp The following types are required: .sp .in +2 .nf int_fast8_t int_fast16_t int_fast32_t int_fast64_t uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t .fi .in -2 All other types of this form are optional. .RE .sp .ne 2 .na \fBInteger types capable of holding object pointers\fR .ad .sp .6 .RS 4n .sp .ne 2 .na \fB\fBintptr_t\fR\fR .ad .RS 13n 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. .RE .sp .ne 2 .na \fB\fBuintptr_t\fR\fR .ad .RS 13n 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. .RE On standard-conforming systems, the \fBintptr_t\fR and \fBuintptr_t\fR types are required; otherwise, they are optional. .RE .sp .ne 2 .na \fBGreatest-width integer types\fR .ad .sp .6 .RS 4n .sp .ne 2 .na \fB\fBintmax_t\fR\fR .ad .RS 13n Designates a signed integer type capable of representing any value of any signed integer type. .RE .sp .ne 2 .na \fB\fBuintmax_t\fR\fR .ad .RS 13n Designates an unsigned integer type capable of representing any value of any unsigned integer type. .RE These types are required. .sp Applications can test for optional types by using the corresponding limit macro from \fBLimits of Specified-Width Integer Types\fR. .RE .SS "Limits of Specified-Width Integer Types" .sp .LP The following macros specify the minimum and maximum limits of the types declared in the <\fBstdint.h\fR> header. Each macro name corresponds to a similar type name in \fBInteger Types\fR. .sp .LP Each instance of any defined macro is replaced by a constant expression suitable for use in \fB#if\fR 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. .sp .ne 2 .na \fBLimits of exact-width integer types\fR .ad .sp .6 .RS 4n .RS +4 .TP .ie t \(bu .el o Minimum values of exact-width signed integer types: .RS .sp .ne 2 .na \fB{\fBINTN_MIN\fR}\fR .ad .RS 14n Exactly -(2^N-1) .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Maximum values of exact-width signed integer types: .RS .sp .ne 2 .na \fB{\fBINTN_MAX\fR}\fR .ad .RS 14n Exactly 2^N-1 -1 .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Maximum values of exact-width unsigned integer types: .RS .sp .ne 2 .na \fB{\fBUINTN_MAX\fR}\fR .ad .RS 15n Exactly 2^N -1 .RE .RE .RE .RE .sp .ne 2 .na \fBLimits of minimum-width integer types\fR .ad .sp .6 .RS 4n .RS +4 .TP .ie t \(bu .el o Minimum values of minimum-width signed integer types: .RS .sp .ne 2 .na \fB{\fBINT_LEAST\fIN\fR_MIN\fR}\fR .ad .RS 20n -(2^N-1 -1) .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Maximum values of minimum-width signed integer types: .RS .sp .ne 2 .na \fB{\fBINT_LEAST\fIN\fR_MAX\fR}\fR .ad .RS 20n 2^N-1 -1 .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Maximum values of minimum-width unsigned integer types: .RS .sp .ne 2 .na \fB{\fBUINT_LEAST\fIN\fR_MAX\fR}\fR .ad .RS 21n 2^N -1 .RE .RE .RE .RE .sp .ne 2 .na \fBLimits of fastest minimum-width integer types\fR .ad .sp .6 .RS 4n .RS +4 .TP .ie t \(bu .el o Minimum values of fastest minimum-width signed integer types: .RS .sp .ne 2 .na \fB{\fBINT_FAST\fIN\fR_MIN\fR}\fR .ad .RS 19n -(2^N-1 -1) .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Maximum values of fastest minimum-width signed integer types: .RS .sp .ne 2 .na \fB{\fBINT_FAST\fIN\fR_MAX\fR}\fR .ad .RS 19n 2^N-1 -1 .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Maximum values of fastest minimum-width unsigned integer types: .RS .sp .ne 2 .na \fB{\fBUINT_FAST\fIN\fR_MAX\fR}\fR .ad .RS 20n 2^N-1 -1 .RE .RE .RE .RE .sp .ne 2 .na \fBLimits of integer types capable of holding object pointers\fR .ad .sp .6 .RS 4n .RS +4 .TP .ie t \(bu .el o Minimum value of pointer-holding signed integer type: .RS .sp .ne 2 .na \fB{\fBINTPTR_MIN\fR}\fR .ad .RS 16n -(2^15 -1) .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Maximum value of pointer-holding signed integer type: .RS .sp .ne 2 .na \fB{\fBINTPTR_MAX\fR}\fR .ad .RS 16n 2^15 -1 .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Minimum value of pointer-holding signed integer type: .RS .sp .ne 2 .na \fB{\fBUINTPTR_MAX\fR}\fR .ad .RS 17n 2^16 -1 .RE .RE .RE .RE .sp .ne 2 .na \fBLimits of greatest-width integer types\fR .ad .sp .6 .RS 4n .RS +4 .TP .ie t \(bu .el o Minimum value of greatest-width signed integer type: .RS .sp .ne 2 .na \fB{\fBINTMAX_MIN\fR}\fR .ad .RS 16n -(2^63 -1) .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Maximum value of greatest-width signed integer type: .RS .sp .ne 2 .na \fB{\fBINTMAX_MIN\fR}\fR .ad .RS 16n 2^63 -1 .RE .RE .RE .RS +4 .TP .ie t \(bu .el o Maximum value of greatest-width unsigned integer type: .RS .sp .ne 2 .na \fB{\fBUINTMAX_MIN\fR}\fR .ad .RS 17n 2^64 -1 .RE .RE .sp .in +2 .nf .fi .in -2 .RE .RE .SS "Limits of Other Integer Types" .sp .LP The following macros specify the minimum and maximum limits of integer types corresponding to types defined in other standard headers. .sp .LP Each instance of these macros is replaced by a constant expression suitable for use in \fB#if\fR 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. .sp .ne 2 .na \fBLimits of \fBptrdiff_t\fR:\fR .ad .RS 27n .sp .ne 2 .na \fB{\fBPTRDIFF_MIN\fR}\fR .ad .RS 17n -65535 .RE .sp .ne 2 .na \fB{\fBPTRDIFF_MAX\fR}\fR .ad .RS 17n +65535 .RE .RE .sp .ne 2 .na \fBLimits of \fBsig_atomic_t\fR:\fR .ad .RS 27n .sp .ne 2 .na \fB{\fBSIG_ATOMIC_MIN\fR}\fR .ad .RS 20n See below. .RE .sp .ne 2 .na \fB{\fBSIG_ATOMIC_MAX\fR}\fR .ad .RS 20n See below. .RE .RE .sp .ne 2 .na \fBLimits of \fBsize_t\fR:\fR .ad .RS 27n .sp .ne 2 .na \fB{\fBSIZE_MAX\fR}\fR .ad .RS 14n 65535 .RE .RE .sp .ne 2 .na \fBLimits of \fBwchar_t\fR:\fR .ad .RS 27n .sp .ne 2 .na \fB{\fBWCHAR_MIN\fR}\fR .ad .RS 15n See below. .RE .sp .ne 2 .na \fB{\fBWCHAR_MAX\fR}\fR .ad .RS 15n See below. .RE .RE .sp .ne 2 .na \fBLimits of \fBwint_t\fR:\fR .ad .RS 27n .sp .ne 2 .na \fB{\fBWINT_MIN\fR}\fR .ad .RS 14n See below. .RE .sp .ne 2 .na \fB{\fBWINT_MAX\fR}\fR .ad .RS 14n See below. .RE .RE .sp .LP If \fBsig_atomic_t\fR (see the <\fBsignal.h\fR> header) is defined as a signed integer type, the value of {\fBSIG_ATOMIC_MIN\fR} is no greater than -127 and the value of {\fBSIG_ATOMIC_MAX\fR} is no less than 127. Otherwise, \fBsig_atomic_t\fR is defined as an unsigned integer type, the value of {\fBSIG_ATOMIC_MIN}\fR is 0, and the value of {\fBSIG_ATOMIC_MAX\fR} is no less than 255. .sp .LP If \fBwchar_t\fR (see the <\fBstddef.h\fR> header) is defined as a signed integer type, the value of {\fBWCHAR_MIN\fR} is no greater than -127 and the value of {\fBWCHAR_MAX\fR} is no less than 127. Otherwise, \fBwchar_t\fR is defined as an unsigned integer type, and the value of {\fBWCHAR_MIN\fR} is 0 and the value of {\fBWCHAR_MAX\fR} is no less than 255. .sp .LP If \fBwint_t\fR (see the <\fBwchar.h\fR> header) is defined as a signed integer type, the value of {\fBWINT_MIN\fR} is no greater than -32767 and the value of {\fBWINT_MAX\fR} is no less than 32767. Otherwise, \fBwint_t\fR is defined as an unsigned integer type, and the value of {\fBWINT_MIN\fR} is 0 and the value of {\fBWINT_MAX\fR} is no less than 65535. .SS "Macros for Integer Constant Expressions" .sp .LP The following macros expand to integer constant expressions suitable for initializing objects that have integer types corresponding to types defined in the <\fBstdint.h\fR> header. Each macro name corresponds to a similar type name listed under minimum-width integer types and greatest-width integer types. .sp .LP Each invocation of one of these macros expands to an integer constant expression suitable for use in \fB#if\fR 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 hexadecimal constant with a value that does not exceed the limits for the corresponding type. .sp .ne 2 .na \fBMacros for minimum-width integer constant expressions\fR .ad .sp .6 .RS 4n The macro \fBINTN_C(\fIvalue\fR)\fR expands to an integer constant expression corresponding to the type \fBint_least\fIN\fR_t\fR. The macro \fBUINTN_C(\fIvalue\fR)\fR expands to an integer constant expression corresponding to the type \fBuint_least\fIN\fR_t\fR. For example, if \fBuint_least64_t\fR is a name for the type unsigned long long, then \fBUINT64_C(0x123)\fR might expand to the integer constant \fB0x123ULL\fR. .RE .sp .ne 2 .na \fBMacros for greatest-width integer constant expressions\fR .ad .sp .6 .RS 4n The following macro expands to an integer constant expression having the value specified by its argument and the type \fBintmax_t\fR: .sp .in +2 .nf INTMAX_C(\fIvalue\fR) .fi .in -2 The following macro expands to an integer constant expression having the value specified by its argument and the type \fBuintmax_t\fR: .sp .in +2 .nf UINTMAX_C(\fIvalue\fR) .fi .in -2 .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Standard .TE .SH SEE ALSO .sp .LP \fBinttypes.h\fR(3HEAD), \fBsignal.h\fR(3HEAD), \fBstddef.h\fR(3HEAD), \fBwchar.h\fR(3HEAD), \fBattributes\fR(5), \fBstandards\fR(5)