.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved .TH "" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" .\" .SH NAME inttypes.h \- fixed size 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 include the \fI\fP header. .LP The \fI\fP header shall include a definition of at least the following type: .TP 7 \fBimaxdiv_t\fP Structure type that is the type of the value returned by the \fIimaxdiv\fP() function. .sp .LP The following macros shall be defined. Each expands to a character string literal containing a conversion specifier, possibly modified by a length modifier, suitable for use within the \fIformat\fP argument of a formatted input/output function when converting the corresponding integer type. These macros have the general form of PRI (character string literals for the \fIfprintf\fP() and \fIfwprintf\fP() family of functions) or SCN (character string literals for the \fIfscanf\fP() and \fIfwscanf\fP() family of functions), followed by the conversion specifier, followed by a name corresponding to a similar type name in \fI\fP. In these names, \fIN\fP represents the width of the type as described in \fI\fP. For example, \fIPRIdFAST32\fP can be used in a format string to print the value of an integer of type \fBint_fast32_t\fP. .LP The \fIfprintf\fP() macros for signed integers are: .TS C center; l2 l2 l2 l2 l. PRId\fIN\fP PRIdLEAST\fIN\fP PRIdFAST\fIN\fP PRIdMAX PRIdPTR PRIi\fIN\fP PRIiLEAST\fIN\fP PRIiFAST\fIN\fP PRIiMAX PRIiPTR .TE .LP The \fIfprintf\fP() macros for unsigned integers are: .TS C center; l2 l2 l2 l2 l. PRIo\fIN\fP PRIoLEAST\fIN\fP PRIoFAST\fIN\fP PRIoMAX PRIoPTR PRIu\fIN\fP PRIuLEAST\fIN\fP PRIuFAST\fIN\fP PRIuMAX PRIuPTR PRIx\fIN\fP PRIxLEAST\fIN\fP PRIxFAST\fIN\fP PRIxMAX PRIxPTR PRIX\fIN\fP PRIXLEAST\fIN\fP PRIXFAST\fIN\fP PRIXMAX PRIXPTR .TE .LP The \fIfscanf\fP() macros for signed integers are: .TS C center; l2 l2 l2 l2 l. SCNd\fIN\fP SCNdLEAST\fIN\fP SCNdFAST\fIN\fP SCNdMAX SCNdPTR SCNi\fIN\fP SCNiLEAST\fIN\fP SCNiFAST\fIN\fP SCNiMAX SCNiPTR .TE .LP The \fIfscanf\fP() macros for unsigned integers are: .TS C center; l2 l2 l2 l2 l. SCNo\fIN\fP SCNoLEAST\fIN\fP SCNoFAST\fIN\fP SCNoMAX SCNoPTR SCNu\fIN\fP SCNuLEAST\fIN\fP SCNuFAST\fIN\fP SCNuMAX SCNuPTR SCNx\fIN\fP SCNxLEAST\fIN\fP SCNxFAST\fIN\fP SCNxMAX SCNxPTR .TE .LP For each type that the implementation provides in \fI\fP, the corresponding \fIfprintf\fP() and \fIfwprintf\fP() macros shall be defined and the corresponding \fIfscanf\fP() and \fIfwscanf\fP() macros shall be defined unless the implementation does not have a suitable modifier for the type. .LP The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided. .sp .RS .nf \fBintmax_t imaxabs(intmax_t); imaxdiv_t imaxdiv(intmax_t, intmax_t); intmax_t strtoimax(const char *restrict, char **restrict, int); uintmax_t strtoumax(const char *restrict, char **restrict, int); intmax_t wcstoimax(const wchar_t *restrict, wchar_t **restrict, int); uintmax_t wcstoumax(const wchar_t *restrict, wchar_t **restrict, int); \fP .fi .RE .SH EXAMPLES .sp .RS .nf \fB#include #include int main(void) { uintmax_t i = UINTMAX_MAX; // This type always exists. wprintf(L"The largest integer value is %020" PRIxMAX "\\n", i); return 0; } \fP .fi .RE .LP \fIThe following sections are informative.\fP .SH APPLICATION USAGE .LP The purpose of \fI\fP is to provide a set of integer types whose definitions are consistent across machines and independent of operating systems and other implementation idiosyncrasies. It defines, via \fBtypedef\fP, integer types of various sizes. Implementations are free to \fBtypedef\fP them as ISO\ C standard integer types or extensions that they support. Consistent use of this header will greatly increase the portability of applications across platforms. .SH RATIONALE .LP The ISO/IEC\ 9899:1990 standard specified that the language should support four signed and unsigned integer data types- \fBchar\fP, \fBshort\fP, \fBint\fP, and \fBlong\fP- but placed very little requirement on their size other than that \fBint\fP and \fBshort\fP be at least 16 bits and \fBlong\fP be at least as long as \fBint\fP and not smaller than 32 bits. For 16-bit systems, most implementations assigned 8, 16, 16, and 32 bits to \fBchar\fP, \fBshort\fP, \fBint\fP, and \fBlong\fP, respectively. For 32-bit systems, the common practice has been to assign 8, 16, 32, and 32 bits to these types. This difference in \fBint\fP size can create some problems for users who migrate from one system to another which assigns different sizes to integer types, because the ISO\ C standard integer promotion rule can produce silent changes unexpectedly. The need for defining an extended integer type increased with the introduction of 64-bit systems. .SH FUTURE DIRECTIONS .LP Macro names beginning with PRI or SCN followed by any lowercase letter or \fB'X'\fP may be added to the macros defined in the \fI\fP header. .SH SEE ALSO .LP The System Interfaces volume of IEEE\ Std\ 1003.1-2001, \fIimaxdiv\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 .