summaryrefslogtreecommitdiffstats
path: root/man0p/stdint.h.0p
blob: 637b4009dd220176ef2d7cfa6deeb5586cd62c95 (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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
.TH "<stdint.h>" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" <stdint.h> 
.SH NAME
stdint.h \- integer types
.SH SYNOPSIS
.LP
\fB#include <stdint.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<stdint.h>\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<stdint.h>\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<stdint.h>\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<stdint.h>\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<signal.h>\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<stddef.h>\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<wchar.h>\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<stdint.h>\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<stdint.h>\fP header is a subset of the \fI<inttypes.h>\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<inttypes.h>\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<stdint.h>\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<stdint.h>\fP header.
.SH SEE ALSO
.LP
\fI<inttypes.h>\fP , \fI<signal.h>\fP , \fI<stddef.h>\fP , \fI<wchar.h>\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 .