summaryrefslogtreecommitdiffstats
path: root/man-pages-posix-2017/man0p/stdint.h.0p
blob: 5acc838c7b8cc5cd9c715b55e26e507bdc02d938 (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
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
'\" et
.TH stdint.h "0P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\"
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.\"
.EQ
delim $$
.EN
.SH NAME
stdint.h
\(em integer types
.SH SYNOPSIS
.LP
.nf
#include <stdint.h>
.fi
.SH DESCRIPTION
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 POSIX.1\(hy2017,
.IR "Section 2.2" ", " "The Compilation Environment")
to enable the visibility of these symbols in this header.
.P
The
.IR <stdint.h> 
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 10
.BR Note:
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
.IR N -bit
signed type has values in the range \-2\s-3\u\fIN\fR\-1\d\s+3 or
1\-2\s-3\u\fIN\fR\-1\d\s+3 to 2\s-3\u\fIN\fR\-1\d\s+3\-1, while
an
.IR N -bit
unsigned type has values in the range 0 to 2\s-3\u\fIN\fR\d\s+3\-1.
.P
.P
Types are defined in the following categories:
.IP " *" 4
Integer types having certain exact widths
.IP " *" 4
Integer types having at least certain specified widths
.IP " *" 4
Fastest integer types having at least certain specified widths
.IP " *" 4
Integer types wide enough to hold pointers to objects
.IP " *" 4
Integer types having greatest width
.P
(Some of these types may denote the same type.)
.P
Corresponding macros specify limits of the declared types and construct
suitable constants.
.P
For each type described herein that the implementation provides, the
.IR <stdint.h> 
header shall declare that
.BR typedef
name and define the associated macros. Conversely, for each type
described herein that the implementation does not provide, the
.IR <stdint.h> 
header shall not declare that
.BR typedef
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"
.P
When
.BR typedef
names differing only in the absence or presence of the initial
.IR u
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.
.P
In the following descriptions, the symbol
.IR N
represents an unsigned decimal integer with no leading zeros (for
example, 8 or 24, but not 04 or 048).
.IP " *" 4
Exact-width integer types
.RS 4 
.P
The
.BR typedef
name
.BR int \c
.IR N \c
.BR _t
designates a signed integer type with width
.IR N ,
no padding bits, and a two's-complement representation. Thus,
.BR int8_t
denotes a signed integer type with a width of exactly 8 bits.
.P
The
.BR typedef
name
.BR uint \c
.IR N \c
.BR _t
designates an unsigned integer type with width
.IR N .
Thus,
.BR uint24_t
denotes an unsigned integer type with a width of exactly 24 bits.
.P
The following types are required:
.P
.nf
.BR int8_t
.BR int16_t
.BR int32_t
.BR uint8_t
.BR uint16_t
.BR uint32_t
.fi
.P
If an implementation provides integer types with width 64 that
meet these requirements, then the following types are required:
.BR int64_t
.BR uint64_t
.P
In particular, this will be the case if any of the following are
true:
.IP -- 4
The implementation supports the _POSIX_V7_ILP32_OFFBIG programming
environment and the application is being built in the
_POSIX_V7_ILP32_OFFBIG programming environment (see the Shell and Utilities volume of POSIX.1\(hy2017,
.IR c99 ,
Programming Environments).
.IP -- 4
The implementation supports the _POSIX_V7_LP64_OFF64 programming
environment and the application is being built in the
_POSIX_V7_LP64_OFF64 programming environment.
.IP -- 4
The implementation supports the _POSIX_V7_LPBIG_OFFBIG programming
environment and the application is being built in the
_POSIX_V7_LPBIG_OFFBIG programming environment.
.P
All other types of this form are optional.
.RE
.IP " *" 4
Minimum-width integer types
.RS 4 
.P
The
.BR typedef
name
.BR int_least \c
.IR N \c
.BR _t
designates a signed integer type with a width of at least
.IR N ,
such that no signed integer type with lesser size has at least the
specified width. Thus,
.BR int_least32_t
denotes a signed integer type with a width of at least 32 bits.
.P
The
.BR typedef
name
.BR uint_least \c
.IR N \c
.BR _t
designates an unsigned integer type with a width of at least
.IR N ,
such that no unsigned integer type with lesser size has at least the
specified width. Thus,
.BR uint_least16_t
denotes an unsigned integer type with a width of at least 16 bits.
.P
The following types are required:
.BR int_least8_t
.BR int_least16_t
.BR int_least32_t
.BR int_least64_t
.BR uint_least8_t
.BR uint_least16_t
.BR uint_least32_t
.BR uint_least64_t
.P
All other types of this form are optional.
.RE
.IP " *" 4
Fastest minimum-width integer types
.RS 4 
.P
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.
.P
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.
.P
The
.BR typedef
name
.BR int_fast \c
.IR N \c
.BR _t
designates the fastest signed integer type with a width of at least
.IR N .
The
.BR typedef
name
.BR uint_fast \c
.IR N \c
.BR _t
designates the fastest unsigned integer type with a width of at least
.IR N .
.P
The following types are required:
.BR int_fast8_t
.BR int_fast16_t
.BR int_fast32_t
.BR int_fast64_t
.BR uint_fast8_t
.BR uint_fast16_t
.BR uint_fast32_t
.BR uint_fast64_t
.P
All other types of this form are optional.
.RE
.IP " *" 4
Integer types capable of holding object pointers
.RS 4 
.P
The following type designates a signed integer type with the property
that any valid pointer to
.BR void
can be converted to this type, then converted back to a pointer to
.BR void ,
and the result will compare equal to the original pointer:
.BR intptr_t
.P
The following type designates an unsigned integer type with the
property that any valid pointer to
.BR void
can be converted to this type, then converted back to a pointer to
.BR void ,
and the result will compare equal to the original pointer:
.BR uintptr_t
.P
On XSI-conformant systems, the
.BR intptr_t
and
.BR uintptr_t
types are required;
otherwise, they are optional.
.RE
.IP " *" 4
Greatest-width integer types
.RS 4 
.P
The following type designates a signed integer type capable of
representing any value of any signed integer type:
.BR intmax_t
.P
The following type designates an unsigned integer type capable of
representing any value of any unsigned integer type:
.BR uintmax_t
.P
These types are required.
.RE
.TP 10
.BR Note:
Applications can test for optional types by using the corresponding
limit macro from
.IR "Limits of Specified-Width Integer Types".
.P
.SS "Limits of Specified-Width Integer Types"
.P
The following macros specify the minimum and maximum limits of the
types declared in the
.IR <stdint.h> 
header. Each macro name corresponds to a similar type name in
.IR "Integer Types".
.P
Each instance of any defined macro shall be replaced by a constant
expression suitable for use in
.BR #if
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 " *" 4
Limits of exact-width integer types
.RS 4 
.IP -- 4
Minimum values of exact-width signed integer types:
.RS 4 
.IP "{INT\fIN\fR_MIN}" 16
Exactly \-($2"^" N\-1$)
.RE
.IP -- 4
Maximum values of exact-width signed integer types:
.RS 4 
.IP "{INT\fIN\fR_MAX}" 16
Exactly $2"^" N\-1$ \-1
.RE
.IP -- 4
Maximum values of exact-width unsigned integer types:
.RS 4 
.IP "{UINT\fIN\fR_MAX}" 16
Exactly $2"^" N$ \-1
.RE
.RE
.IP " *" 4
Limits of minimum-width integer types
.RS 4 
.IP -- 4
Minimum values of minimum-width signed integer types:
.RS 4 
.IP "{INT_LEAST\fIN\fR_MIN}" 16
\-($2"^" N\-1$ \-1)
.RE
.IP -- 4
Maximum values of minimum-width signed integer types:
.RS 4 
.IP "{INT_LEAST\fIN\fR_MAX}" 16
$2"^" N\-1$ \-1
.RE
.IP -- 4
Maximum values of minimum-width unsigned integer types:
.RS 4 
.IP "{UINT_LEAST\fIN\fR_MAX}" 16
$2"^" N$ \-1
.RE
.RE
.IP " *" 4
Limits of fastest minimum-width integer types
.RS 4 
.IP -- 4
Minimum values of fastest minimum-width signed integer types:
.RS 4 
.IP "{INT_FAST\fIN\fR_MIN}" 16
\-($2"^" N\-1$ \-1)
.RE
.IP -- 4
Maximum values of fastest minimum-width signed integer types:
.RS 4 
.IP "{INT_FAST\fIN\fR_MAX}" 16
$2"^" N\-1$ \-1
.RE
.IP -- 4
Maximum values of fastest minimum-width unsigned integer types:
.RS 4 
.IP "{UINT_FAST\fIN\fR_MAX}" 16
$2"^" N$ \-1
.RE
.RE
.IP " *" 4
Limits of integer types capable of holding object pointers
.RS 4 
.IP -- 4
Minimum value of pointer-holding signed integer type:
.RS 4 
.IP {INTPTR_MIN} 16
\-($2"^" 15$ \-1)
.RE
.IP -- 4
Maximum value of pointer-holding signed integer type:
.RS 4 
.IP {INTPTR_MAX} 16
$2"^" 15$ \-1
.RE
.IP -- 4
Maximum value of pointer-holding unsigned integer type:
.RS 4 
.IP {UINTPTR_MAX} 16
$2"^" 16$ \-1
.RE
.RE
.IP " *" 4
Limits of greatest-width integer types
.RS 4 
.IP -- 4
Minimum value of greatest-width signed integer type:
.RS 4 
.IP {INTMAX_MIN} 16
\-($2"^" 63$ \-1)
.RE
.IP -- 4
Maximum value of greatest-width signed integer type:
.RS 4 
.IP {INTMAX_MAX} 16
$2"^" 63$ \-1
.RE
.IP -- 4
Maximum value of greatest-width unsigned integer type:
.RS 4 
.IP {UINTMAX_MAX} 16
$2"^" 64$ \-1
.RE
.RE
.SS "Limits of Other Integer Types"
.P
The following macros specify the minimum and maximum limits of integer
types corresponding to types defined in other standard headers.
.P
Each instance of these macros shall be replaced by a constant
expression suitable for use in
.BR #if
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 " *" 4
Limits of \fBptrdiff_t\fR:
.RS 4 
.IP {PTRDIFF_MIN} 16
\-65\|535
.IP {PTRDIFF_MAX} 16
+65\|535
.RE
.IP " *" 4
Limits of \fBsig_atomic_t\fR:
.RS 4 
.IP {SIG_ATOMIC_MIN} 16
See below.
.IP {SIG_ATOMIC_MAX} 16
See below.
.RE
.IP " *" 4
Limit of \fBsize_t\fR:
.RS 4 
.IP {SIZE_MAX} 16
65\|535
.RE
.IP " *" 4
Limits of \fBwchar_t\fR:
.RS 4 
.IP {WCHAR_MIN} 16
See below.
.IP {WCHAR_MAX} 16
See below.
.RE
.IP " *" 4
Limits of \fBwint_t\fR:
.RS 4 
.IP {WINT_MIN} 16
See below.
.IP {WINT_MAX} 16
See below.
.RE
.P
If
.BR sig_atomic_t
(see the
.IR <signal.h> 
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,
.BR sig_atomic_t
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.
.P
If
.BR wchar_t
(see the
.IR <stddef.h> 
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,
.BR wchar_t
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.
.P
If
.BR wint_t
(see the
.IR <wchar.h> 
header) is defined as a signed integer type, the value of
{WINT_MIN}
shall be no greater than \-32\|767 and the value of
{WINT_MAX}
shall be no less than 32\|767; otherwise,
.BR wint_t
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 65\|535.
.SS "Macros for Integer Constant Expressions"
.P
The following macros expand to integer constant expressions suitable for
initializing objects that have integer types corresponding to types
defined in the
.IR <stdint.h> 
header. Each macro name corresponds to a similar type name listed under
\fIMinimum-width integer types\fR and \fIGreatest-width integer
types\fR.
.P
Each invocation of one of these macros shall expand to an integer
constant expression suitable for use in
.BR #if
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.
.P
The argument in any instance of these macros shall be an unsuffixed
integer constant with a value that does not exceed the limits for the
corresponding type.
.IP " *" 4
Macros for minimum-width integer constant expressions
.RS 4 
.P
The macro
.IR INTN_C (\c
.IR value )
shall expand to an integer constant expression corresponding to the
type
.BR int_least \c
.IR N \c
.BR _t .
The macro
.IR UINTN_C (\c
.IR value )
shall expand to an integer constant expression corresponding to the
type
.BR uint_least \c
.IR N \c
.BR _t .
For example, if
.BR uint_least64_t
is a name for the type
.BR "unsigned long long" ,
then
.IR UINT64_C (0x123)
might expand to the integer constant 0x123ULL.
.RE
.IP " *" 4
Macros for greatest-width integer constant expressions
.RS 4 
.P
The following macro expands to an integer constant expression having
the value specified by its argument and the type
.BR intmax_t :
INTMAX_C(\fIvalue\fR)
.P
The following macro expands to an integer constant expression having
the value specified by its argument and the type
.BR uintmax_t :
UINTMAX_C(\fIvalue\fR)
.RE
.LP
.IR "The following sections are informative."
.SH "APPLICATION USAGE"
None.
.SH RATIONALE
The
.IR <stdint.h> 
header is a subset of the
.IR <inttypes.h> 
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
.IR <inttypes.h> 
header avoids defining such a large number of macros.
.br
.P
As a consequence of adding
.BR int8_t ,
the following are true:
.IP " *" 4
A byte is exactly 8 bits.
.IP " *" 4
{CHAR_BIT}
has the value 8,
{SCHAR_MAX}
has the value 127,
{SCHAR_MIN}
has the value \-128, and
{UCHAR_MAX}
has the value 255.
.P
(The POSIX standard explicitly requires 8-bit char and
two's-complement arithmetic.)
.SH "FUTURE DIRECTIONS"
.BR typedef
names beginning with
.BR int
or
.BR uint
and ending with _t may be added to the types defined in the
.IR <stdint.h> 
header. Macro names beginning with INT or UINT and ending with _MAX,
_MIN, or _C may be added to the macros defined in the
.IR <stdint.h> 
header.
.SH "SEE ALSO"
.IR "\fB<inttypes.h>\fP",
.IR "\fB<signal.h>\fP",
.IR "\fB<stddef.h>\fP",
.IR "\fB<wchar.h>\fP"
.P
The System Interfaces volume of POSIX.1\(hy2017,
.IR "Section 2.2" ", " "The Compilation Environment"
.\"
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1-2017, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 7, 2018 Edition,
Copyright (C) 2018 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 .
.PP
Any typographical or formatting errors that appear
in this page are most likely
to have been introduced during the conversion of the source files to
man page format. To report such errors, see
https://www.kernel.org/doc/man-pages/reporting_bugs.html .