Debian Codegraph @

upstream/mageia-cauldron/man3type/intN_t.3type

raw
1 .\" Copyright 2020, Michael Kerrisk <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH intN_t 3type 2026-02-08 "Linux man-pages 6.17"
7 .SH NAME
8 intN_t, int8_t, int16_t, int32_t, int64_t,
9 uintN_t, uint8_t, uint16_t, uint32_t, uint64_t
10 \- fixed-width basic integer types
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc )
14 .SH SYNOPSIS
15 .nf
16 .B #include <stdint.h>
17 .P
18 .BR typedef " /* ... */ " int8_t;
19 .BR typedef " /* ... */ " int16_t;
20 .BR typedef " /* ... */ " int32_t;
21 .BR typedef " /* ... */ " int64_t;
22 .P
23 .BR typedef " /* ... */ " uint8_t;
24 .BR typedef " /* ... */ " uint16_t;
25 .BR typedef " /* ... */ " uint32_t;
26 .BR typedef " /* ... */ " uint64_t;
27 .P
28 .B "#define INT8_WIDTH 8"
29 .B "#define INT16_WIDTH 16"
30 .B "#define INT32_WIDTH 32"
31 .B "#define INT64_WIDTH 64"
32 .P
33 .B "#define UINT8_WIDTH 8"
34 .B "#define UINT16_WIDTH 16"
35 .B "#define UINT32_WIDTH 32"
36 .B "#define UINT64_WIDTH 64"
37 .P
38 .BR "#define INT8_MAX " "/* 2**(INT8_WIDTH - 1) - 1 */"
39 .BR "#define INT16_MAX " "/* 2**(INT16_WIDTH - 1) - 1 */"
40 .BR "#define INT32_MAX " "/* 2**(INT32_WIDTH - 1) - 1 */"
41 .BR "#define INT64_MAX " "/* 2**(INT64_WIDTH - 1) - 1 */"
42 .P
43 .BR "#define INT8_MIN " "/* - 2**(INT8_WIDTH - 1) */"
44 .BR "#define INT16_MIN " "/* - 2**(INT16_WIDTH - 1) */"
45 .BR "#define INT32_MIN " "/* - 2**(INT32_WIDTH - 1) */"
46 .BR "#define INT64_MIN " "/* - 2**(INT64_WIDTH - 1) */"
47 .P
48 .BR "#define UINT8_MAX " "/* 2**INT8_WIDTH - 1 */"
49 .BR "#define UINT16_MAX " "/* 2**INT16_WIDTH - 1 */"
50 .BR "#define UINT32_MAX " "/* 2**INT32_WIDTH - 1 */"
51 .BR "#define UINT64_MAX " "/* 2**INT64_WIDTH - 1 */"
52 .P
53 .BI "#define INT8_C(" c ") " c " ## " "\f[R]/* ... */\f[]"
54 .BI "#define INT16_C(" c ") " c " ## " "\f[R]/* ... */\f[]"
55 .BI "#define INT32_C(" c ") " c " ## " "\f[R]/* ... */\f[]"
56 .BI "#define INT64_C(" c ") " c " ## " "\f[R]/* ... */\f[]"
57 .P
58 .BI "#define UINT8_C(" c ") " c " ## " "\f[R]/* ... */\f[]"
59 .BI "#define UINT16_C(" c ") " c " ## " "\f[R]/* ... */\f[]"
60 .BI "#define UINT32_C(" c ") " c " ## " "\f[R]/* ... */\f[]"
61 .BI "#define UINT64_C(" c ") " c " ## " "\f[R]/* ... */\f[]"
62 .fi
63 .SH DESCRIPTION
64 .IR int N _t
65 are
66 signed integer types
67 of a fixed width of exactly N bits,
68 .I N
69 being the value specified in its type name.
70 They are be capable of storing values in the range
71 .RB [ INT \f[I]N\f[] _MIN ,
72 .BR INT \f[I]N\f[] _MAX ],
73 substituting
74 .I N
75 by the appropriate number.
76 .P
77 .IR uint N _t
78 are
79 unsigned integer types
80 of a fixed width of exactly N bits,
81 N being the value specified in its type name.
82 They are capable of storing values in the range
83 .RB [ 0 ,
84 .BR UINT \f[I]N\f[] _MAX ],
85 substituting
86 .I N
87 by the appropriate number.
88 .P
89 According to POSIX,
90 .RI [ u ] int8_t ,
91 .RI [ u ] int16_t ,
92 and
93 .RI [ u ] int32_t
94 are required;
95 .RI [ u ] int64_t
96 are only required in implementations that provide integer types with width 64;
97 and all other types of this form are optional.
98 .P
99 The macros
100 .RB [ U ] INT \f[I]N\f[] _WIDTH
101 expand to the width in bits of these types
102 .RI ( N ).
103 .P
104 The macros
105 .RB [ U ] INT \f[I]N\f[] _MAX
106 expand to the maximum value that these types can hold.
107 .P
108 The macros
109 .BI INT N _MIN
110 expand to the minimum value that these types can hold.
111 .P
112 The macros
113 .RB [ U ] INT \f[I]N\f[] _C ()
114 expand their argument to an integer constant of type
115 .RI [ u ] int N _t .
116 .P
117 The length modifiers for the
118 .RI [ u ] int N _t
119 types for the
120 .BR printf (3)
121 family of functions
122 are expanded by macros of the forms
123 .BR PRId \f[I]N\f[],
124 .BR PRIi \f[I]N\f[],
125 .BR PRIu \f[I]N\f[],
126 and
127 .BI PRIx N
128 (defined in
129 .IR <inttypes.h> );
130 resulting for example in
131 .B %"PRId64"
132 or
133 .B %"PRIi64"
134 for printing
135 .I int64_t
136 values.
137 The length modifiers for the
138 .RI [ u ] int N _t
139 types for the
140 .BR scanf (3)
141 family of functions
142 are expanded by macros of the forms
143 .BR SCNd \f[I]N\f[],
144 .BR SCNi \f[I]N\f[],
145 .BR SCNu \f[I]N\f[],
146 and
147 .BI SCNx N,
148 (defined in
149 .IR <inttypes.h> );
150 resulting for example in
151 .B %"SCNu8"
152 or
153 .B %"SCNx8"
154 for scanning
155 .I uint8_t
156 values.
157 .SH STANDARDS
158 C23, POSIX.1-2024.
159 .SH HISTORY
160 .TP
161 .RI [ u ] int N _t
162 C99,
163 SUSv2,
164 POSIX.1-2001.
165 .TP
166 .RB [ U ] INT \f[I]N\f[] _MAX
167 .TQ
168 .BI INT N _MIN
169 .TQ
170 .RB [ U ] INT \f[I]N\f[] _C ()
171 C99, POSIX.1-2001.
172 .TP
173 .RB [ U ] INT \f[I]N\f[] _WIDTH
174 C23.
175 .P
176 Initially, SUSv2 did not include
177 .I <stdint.h>
178 as a standard header.
179 The
180 .RI [ u ] int N _t
181 types were instead defined in
182 .IR <inttypes.h> .
183 This was remedied in POSIX.1-2001.
184 .SH NOTES
185 The following header also provides these types:
186 .IR <inttypes.h> .
187 .I <arpa/inet.h>
188 also provides
189 .I uint16_t
190 and
191 .IR uint32_t .
192 .SH SEE ALSO
193 .BR intmax_t (3type),
194 .BR intptr_t (3type),
195 .BR printf (3)