1stdint.h(3HEAD)                     Headers                    stdint.h(3HEAD)
2
3
4

NAME

6       stdint.h, stdint - integer types
7

SYNOPSIS

9       #include <stdint.h>
10
11

DESCRIPTION

13       The  <stdint.h>  header declares sets of integer types having specified
14       widths, and defines corresponding  sets  of  macros.  It  also  defines
15       macros  that  specify  limits  of  integer types corresponding to types
16       defined in other standard headers.
17
18
19       The ``width'' of an integer type is the number of bits  used  to  store
20       its  value  in  a pure binary system; the actual type can use more bits
21       than that (for example, a 28-bit type could be stored  in  32  bits  of
22       actual storage). An N-bit signed type has values in the range -2^N-1 or
23       1-2^N-1 to 2^N-1-1, while an N-bit unsigned  type  has  values  in  the
24       range 0 to 2^N-1.
25
26
27       Types are defined in the following categories:
28
29           o      integer types having certain exact widths
30
31           o      integer types having at least certain specified widths
32
33           o      fastest  integer  types  having  at  least certain specified
34                  widths
35
36           o      integer types wide enough to hold pointers to objects
37
38           o      integer types having greatest width
39
40
41       Some of these types may denote the same type.
42
43
44       Corresponding macros specify limits of the declared types and construct
45       suitable constants.
46
47
48       For  each  type  described herein that the implementation provides, the
49       <stdint.h> header declares that typedef name and defines the associated
50       macros. Conversely, for each type described herein that the implementa‐
51       tion does not provide, the <stdint.h>  header  does  not  declare  that
52       typedef  name, nor does it define the associated macros. An implementa‐
53       tion provides those types described as required, but need  not  provide
54       any of the others (described as optional).
55
56   Integer Types
57       When  typedef  names  differing  only in the absence or presence of the
58       initial u are defined, they denote corresponding  signed  and  unsigned
59       types  as  described in the ISO/IEC 9899: 1999 standard, Section 6.2.5;
60       an implementation providing one of these corresponding types must  also
61       provide the other.
62
63
64       In the following descriptions, the symbol N represents an unsigned dec‐
65       imal integer with no leading zeros (for example, 8 or 24, but not 04 or
66       048).
67
68       Exact-width integer types
69
70           The typedef name intN_t designates a signed integer type with width
71           N, no padding bits, and a  two's-complement  representation.  Thus,
72           int8_t  denotes  a  signed  integer  type with a width of exactly 8
73           bits.
74
75           The typedef name uintN_t designates an unsigned integer  type  with
76           width  N.  Thus,  uint24_t  denotes an unsigned integer type with a
77           width of exactly 24 bits.
78
79           The following types are required:
80
81             int8_t
82             int16_t
83             int32_t
84             uint8_t
85             uint16_t
86             uint32_t
87
88           If an implementation provides integer types with width 64 that meet
89           these requirements, then the following types are required:
90
91             int64_t
92             uint64_t
93
94           In particular, this is the case if any of the following are  true:
95
96               o      The  implementation  supports the _POSIX_V6_ILP32_OFFBIG
97                      programming environment and  the  application  is  being
98                      built  in  the _POSI X_V6_ILP32_OFFBIG programming envi‐
99                      ronment (see the Shell and Utilities volume of IEEE  Std
100                      1003.1-200x, c99, Programming Environments).
101
102               o      The  implementation  supports  the  _POSIX_V6_LP64_OFF64
103                      programming environment and  the  application  is  being
104                      built  in the _POSIX_ V6_LP64_OFF64 programming environ‐
105                      ment.
106
107               o      The implementation supports  the  _POSIX_V6_LPBIG_OFFBIG
108                      programming  environment  and  the  application is being
109                      built in the _POSIX_V6_LPBIG_OFFBIG programming environ‐
110                      ment.
111           All other types of this form are optional.
112
113
114       Minimum-width integer types
115
116           The typedef name int_leastN_t designates a signed integer type with
117           a width of at least N, such that no signed integer type with lesser
118           size has at least the specified width. Thus, int_least32 _t denotes
119           a signed integer type with a width of at least 32 bits.
120
121           The typedef name uint_leastN_t designates an unsigned integer  type
122           with a width of at least N, such that no unsigned integer type with
123           lesser size has at least the specified width. Thus, uint_ least16_t
124           denotes an unsigned integer type with a width of at least 16 bits.
125
126           The following types are required:
127
128             int_least8_t
129             int_least16_t
130             int_least32_t
131             int_least64_t
132             uint_least8_t
133             uint_least16_t
134             uint_least32_t
135             uint_least64_t
136
137           All other types of this form are optional.
138
139
140       Fastest minimum-width integer types
141
142           Each of the following types designates an integer type that is usu‐
143           ally fastest to operate with among all integer types that  have  at
144           least the specified width.
145
146           The  designated  type  is not guaranteed to be fastest for all pur‐
147           poses; if the implementation has no clear grounds for choosing  one
148           type over another, it will simply pick some integer type satisfying
149           the signedness and width requirements.
150
151           The typedef name int_fastN_t designates the fastest signed  integer
152           type  with  a  width  of at least N. The typedef name uint_fastN_ t
153           designates the fastest unsigned integer type with  a  width  of  at
154           least N.
155
156           The following types are required:
157
158             int_fast8_t
159             int_fast16_t
160             int_fast32_t
161             int_fast64_t
162             uint_fast8_t
163             uint_fast16_t
164             uint_fast32_t
165             uint_fast64_t
166
167           All other types of this form are optional.
168
169
170       Integer types capable of holding object pointers
171
172
173           intptr_t     Designates  a  signed  integer  type with the property
174                        that any valid pointer to void  can  be  converted  to
175                        this  type,  then converted back to a pointer to void,
176                        and the result will  compare  equal  to  the  original
177                        pointer.
178
179
180           uintptr_t    Designates  an unsigned integer type with the property
181                        that any valid pointer to void  can  be  converted  to
182                        this  type,  then converted back to a pointer to void,
183                        and the result will  compare  equal  to  the  original
184                        pointer.
185
186           On  standard-conforming  systems,  the intptr_t and uintptr_t types
187           are required; otherwise, they are optional.
188
189
190       Greatest-width integer types
191
192
193           intmax_t     Designates a signed integer type capable of represent‐
194                        ing any value of any signed integer type.
195
196
197           uintmax_t    Designates  an unsigned integer type capable of repre‐
198                        senting any value of any unsigned integer type.
199
200           These types are required.
201
202           Applications can test for optional types by using the corresponding
203           limit macro from Limits of Specified-Width Integer Types.
204
205
206   Limits of Specified-Width Integer Types
207       The  following  macros  specify  the  minimum and maximum limits of the
208       types declared in the <stdint.h> header. Each macro name corresponds to
209       a similar type name in Integer Types.
210
211
212       Each instance of any defined macro is replaced by a constant expression
213       suitable for use in #if preprocessing directives. This  expression  has
214       the  same  type  as would an expression that is an object of the corre‐
215       sponding type converted according to the integer promotions. Its imple‐
216       mentation-defined  value  is equal to or greater in magnitude (absolute
217       value) than the corresponding value  given below, with the  same  sign,
218       except where stated to be exactly the given value.
219
220       Limits of exact-width integer types
221
222
223               o      Minimum values of exact-width signed integer types:
224
225
226                      {INTN_MIN}    Exactly -(2^N-1)
227
228
229
230               o      Maximum values of exact-width signed integer types:
231
232
233                      {INTN_MAX}    Exactly 2^N-1 -1
234
235
236
237               o      Maximum values of exact-width unsigned integer types:
238
239
240                      {UINTN_MAX}    Exactly 2^N -1
241
242
243
244
245       Limits of minimum-width integer types
246
247
248               o      Minimum values of minimum-width signed integer types:
249
250
251                      {INT_LEASTN_MIN}    -(2^N-1 -1)
252
253
254
255               o      Maximum values of minimum-width signed integer types:
256
257
258                      {INT_LEASTN_MAX}    2^N-1 -1
259
260
261
262               o      Maximum values of minimum-width unsigned integer types:
263
264
265                      {UINT_LEASTN_MAX}    2^N -1
266
267
268
269
270       Limits of fastest minimum-width integer types
271
272
273               o      Minimum  values  of fastest minimum-width signed integer
274                      types:
275
276
277                      {INT_FASTN_MIN}    -(2^N-1 -1)
278
279
280
281               o      Maximum values of fastest minimum-width  signed  integer
282                      types:
283
284
285                      {INT_FASTN_MAX}    2^N-1 -1
286
287
288
289               o      Maximum values of fastest minimum-width unsigned integer
290                      types:
291
292
293                      {UINT_FASTN_MAX}    2^N-1 -1
294
295
296
297
298       Limits of integer types capable of holding object pointers
299
300
301               o      Minimum value of pointer-holding signed integer type:
302
303
304                      {INTPTR_MIN}    -(2^15 -1)
305
306
307
308               o      Maximum value of pointer-holding signed integer type:
309
310
311                      {INTPTR_MAX}    2^15 -1
312
313
314
315               o      Minimum value of pointer-holding signed integer type:
316
317
318                      {UINTPTR_MAX}    2^16 -1
319
320
321
322
323       Limits of greatest-width integer types
324
325
326               o      Minimum value of greatest-width signed integer type:
327
328
329                      {INTMAX_MIN}    -(2^63 -1)
330
331
332
333               o      Maximum value of greatest-width signed integer type:
334
335
336                      {INTMAX_MIN}    2^63 -1
337
338
339
340               o      Maximum value of greatest-width unsigned integer type:
341
342
343                      {UINTMAX_MIN}    2^64 -1
344
345
346
347
348
349
350
351   Limits of Other Integer Types
352       The following macros specify the minimum and maximum limits of  integer
353       types corresponding to types defined in other standard headers.
354
355
356       Each  instance  of  these  macros  is replaced by a constant expression
357       suitable for use in #if preprocessing directives. This  expression  has
358       the  same  type  as would an expression that is an object of the corre‐
359       sponding type converted according to the integer promotions. Its imple‐
360       mentation-defined  value  is equal to or greater in magnitude (absolute
361       value) than the corresponding value given below, with the same sign.
362
363       Limits of ptrdiff_t:
364                                  {PTRDIFF_MIN}    -65535
365
366
367                                  {PTRDIFF_MAX}    +65535
368
369
370
371       Limits of sig_atomic_t:
372                                  {SIG_ATOMIC_MIN}    See below.
373
374
375                                  {SIG_ATOMIC_MAX}    See below.
376
377
378
379       Limits of size_t:
380                                  {SIZE_MAX}    65535
381
382
383
384       Limits of wchar_t:
385                                  {WCHAR_MIN}    See below.
386
387
388                                  {WCHAR_MAX}    See below.
389
390
391
392       Limits of wint_t:
393                                  {WINT_MIN}    See below.
394
395
396                                  {WINT_MAX}    See below.
397
398
399
400
401       If sig_atomic_t (see the <signal.h> header)  is  defined  as  a  signed
402       integer type, the value of {SIG_ATOMIC_MIN} is no greater than -127 and
403       the  value  of  {SIG_ATOMIC_MAX}  is  no  less  than  127.   Otherwise,
404       sig_atomic_t  is  defined  as  an  unsigned  integer type, the value of
405       {SIG_ATOMIC_MIN} is 0, and the value of  {SIG_ATOMIC_MAX}  is  no  less
406       than 255.
407
408
409       If  wchar_t  (see the <stddef.h> header) is defined as a signed integer
410       type, the value of {WCHAR_MIN} is no greater than -127 and   the  value
411       of {WCHAR_MAX} is no less than 127. Otherwise, wchar_t is defined as an
412       unsigned integer type, and the value of {WCHAR_MIN} is 0 and the  value
413       of {WCHAR_MAX} is no less than 255.
414
415
416       If  wint_t  (see  the  <wchar.h> header) is defined as a signed integer
417       type, the value of {WINT_MIN} is no greater than -32767 and  the  value
418       of {WINT_MAX} is no less than 32767. Otherwise, wint_t is defined as an
419       unsigned integer type, and the value of {WINT_MIN} is 0 and  the  value
420       of {WINT_MAX} is no less than 65535.
421
422   Macros for Integer Constant Expressions
423       The  following  macros  expand to integer constant expressions suitable
424       for initializing objects that have integer types corresponding to types
425       defined in the <stdint.h> header. Each macro name corresponds to a sim‐
426       ilar type name listed under minimum-width integer types  and  greatest-
427       width integer types.
428
429
430       Each  invocation  of one of these macros expands to an integer constant
431       expression suitable for use in #if preprocessing directives.  The  type
432       of  the  expression has the same type as would an expression that is an
433       object of the corresponding type converted  according  to  the  integer
434       promotions.  The  value  of the expression is that of the argument. The
435       argument in any instance of these macros is a decimal, octal, or  hexa‐
436       decimal  constant  with a value that does not exceed the limits for the
437       corresponding type.
438
439       Macros for minimum-width integer constant expressions
440
441           The macro INTN_C(value) expands to an integer  constant  expression
442           corresponding  to  the  type int_leastN_t. The macro UINTN_C(value)
443           expands to an integer constant expression corresponding to the type
444           uint_leastN_t.  For  example,  if  uint_least64_t is a name for the
445           type unsigned long long, then UINT64_C(0x123) might expand  to  the
446           integer constant 0x123ULL.
447
448
449       Macros for greatest-width integer constant expressions
450
451           The  following macro expands to an integer constant expression hav‐
452           ing the value specified by its argument and the type intmax_t:
453
454             INTMAX_C(value)
455
456           The following macro expands to an integer constant expression  hav‐
457           ing the value specified by its argument and the type uintmax_t:
458
459             UINTMAX_C(value)
460
461
462

ATTRIBUTES

464       See attributes(5) for descriptions of the following attributes:
465
466
467
468
469       ┌─────────────────────────────┬─────────────────────────────┐
470       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
471       ├─────────────────────────────┼─────────────────────────────┤
472       │Interface Stability          │Standard                     │
473       └─────────────────────────────┴─────────────────────────────┘
474

SEE ALSO

476       inttypes.h(3HEAD),  signal.h(3HEAD),  stddef.h(3HEAD),  wchar.h(3HEAD),
477       attributes(5), standards(5)
478
479
480
481SunOS 5.11                        10 Sep 2004                  stdint.h(3HEAD)
Impressum