summaryrefslogtreecommitdiffstats
path: root/man-pages-posix-2003/man0p/inttypes.h.0p
blob: 3412f104dda32fdf8a50ac6dc9c97aef02b0ebfd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "<inttypes.h>" 0P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" <inttypes.h> 
.SH NAME
inttypes.h \- fixed size integer types
.SH SYNOPSIS
.LP
\fB#include <inttypes.h>\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<inttypes.h>\fP header shall include the \fI<stdint.h>\fP
header.
.LP
The \fI<inttypes.h>\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<stdint.h>\fP. In these
names, \fIN\fP
represents the width of the type as described in \fI<stdint.h>\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<stdint.h>\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 <inttypes.h>
#include <wchar.h>
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<inttypes.h>\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<inttypes.h>\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 .