avr-libc  2.1.0
Standard C library for AVR-GCC

AVR Libc Home Page

AVRs

AVR Libc Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

inttypes.h
Go to the documentation of this file.
1 /* Copyright (c) 2004,2005,2007,2012 Joerg Wunsch
2  Copyright (c) 2005, Carlos Lamas
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright
9  notice, this list of conditions and the following disclaimer.
10 
11  * Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16  * Neither the name of the copyright holders nor the names of
17  contributors may be used to endorse or promote products derived
18  from this software without specific prior written permission.
19 
20  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  POSSIBILITY OF SUCH DAMAGE. */
31 
32 /* $Id: inttypes_8h_source.html,v 1.1.1.7 2022/01/29 09:22:01 joerg_wunsch Exp $ */
33 
34 #ifndef __INTTYPES_H_
35 #define __INTTYPES_H_
36 
37 #include <stdint.h>
38 
39 /** \file */
40 /** \defgroup avr_inttypes <inttypes.h>: Integer Type conversions
41  \code #include <inttypes.h> \endcode
42 
43  This header file includes the exact-width integer definitions from
44  <tt><stdint.h></tt>, and extends them with additional facilities
45  provided by the implementation.
46 
47  Currently, the extensions include two additional integer types
48  that could hold a "far" pointer (i.e. a code pointer that can
49  address more than 64 KB), as well as standard names for all printf
50  and scanf formatting options that are supported by the \ref avr_stdio.
51  As the library does not support the full range of conversion
52  specifiers from ISO 9899:1999, only those conversions that are
53  actually implemented will be listed here.
54 
55  The idea behind these conversion macros is that, for each of the
56  types defined by <stdint.h>, a macro will be supplied that portably
57  allows formatting an object of that type in printf() or scanf()
58  operations. Example:
59 
60  \code
61  #include <inttypes.h>
62 
63  uint8_t smallval;
64  int32_t longval;
65  ...
66  printf("The hexadecimal value of smallval is %" PRIx8
67  ", the decimal value of longval is %" PRId32 ".\n",
68  smallval, longval);
69  \endcode
70 */
71 
72 /** \name Far pointers for memory access >64K */
73 
74 /*@{*/
75 /** \ingroup avr_inttypes
76  signed integer type that can hold a pointer > 64 KB */
78 
79 /** \ingroup avr_inttypes
80  unsigned integer type that can hold a pointer > 64 KB */
82 /*@}*/
83 
84 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
85 
86 
87 /** \name macros for printf and scanf format specifiers
88 
89  For C++, these are only included if __STDC_LIMIT_MACROS
90  is defined before including <inttypes.h>.
91  */
92 
93 /*@{*/
94 /** \ingroup avr_inttypes
95  decimal printf format for int8_t */
96 #define PRId8 "d"
97 /** \ingroup avr_inttypes
98  decimal printf format for int_least8_t */
99 #define PRIdLEAST8 "d"
100 /** \ingroup avr_inttypes
101  decimal printf format for int_fast8_t */
102 #define PRIdFAST8 "d"
103 
104 /** \ingroup avr_inttypes
105  integer printf format for int8_t */
106 #define PRIi8 "i"
107 /** \ingroup avr_inttypes
108  integer printf format for int_least8_t */
109 #define PRIiLEAST8 "i"
110 /** \ingroup avr_inttypes
111  integer printf format for int_fast8_t */
112 #define PRIiFAST8 "i"
113 
114 
115 /** \ingroup avr_inttypes
116  decimal printf format for int16_t */
117 #define PRId16 "d"
118 /** \ingroup avr_inttypes
119  decimal printf format for int_least16_t */
120 #define PRIdLEAST16 "d"
121 /** \ingroup avr_inttypes
122  decimal printf format for int_fast16_t */
123 #define PRIdFAST16 "d"
124 
125 /** \ingroup avr_inttypes
126  integer printf format for int16_t */
127 #define PRIi16 "i"
128 /** \ingroup avr_inttypes
129  integer printf format for int_least16_t */
130 #define PRIiLEAST16 "i"
131 /** \ingroup avr_inttypes
132  integer printf format for int_fast16_t */
133 #define PRIiFAST16 "i"
134 
135 
136 /** \ingroup avr_inttypes
137  decimal printf format for int32_t */
138 #define PRId32 "ld"
139 /** \ingroup avr_inttypes
140  decimal printf format for int_least32_t */
141 #define PRIdLEAST32 "ld"
142 /** \ingroup avr_inttypes
143  decimal printf format for int_fast32_t */
144 #define PRIdFAST32 "ld"
145 
146 /** \ingroup avr_inttypes
147  integer printf format for int32_t */
148 #define PRIi32 "li"
149 /** \ingroup avr_inttypes
150  integer printf format for int_least32_t */
151 #define PRIiLEAST32 "li"
152 /** \ingroup avr_inttypes
153  integer printf format for int_fast32_t */
154 #define PRIiFAST32 "li"
155 
156 
157 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
158 
159 #define PRId64 "lld"
160 #define PRIdLEAST64 "lld"
161 #define PRIdFAST64 "lld"
162 
163 #define PRIi64 "lli"
164 #define PRIiLEAST64 "lli"
165 #define PRIiFAST64 "lli"
166 
167 
168 #define PRIdMAX "lld"
169 #define PRIiMAX "lli"
170 
171 #endif
172 
173 /** \ingroup avr_inttypes
174  decimal printf format for intptr_t */
175 #define PRIdPTR PRId16
176 /** \ingroup avr_inttypes
177  integer printf format for intptr_t */
178 #define PRIiPTR PRIi16
179 
180 /** \ingroup avr_inttypes
181  octal printf format for uint8_t */
182 #define PRIo8 "o"
183 /** \ingroup avr_inttypes
184  octal printf format for uint_least8_t */
185 #define PRIoLEAST8 "o"
186 /** \ingroup avr_inttypes
187  octal printf format for uint_fast8_t */
188 #define PRIoFAST8 "o"
189 
190 /** \ingroup avr_inttypes
191  decimal printf format for uint8_t */
192 #define PRIu8 "u"
193 /** \ingroup avr_inttypes
194  decimal printf format for uint_least8_t */
195 #define PRIuLEAST8 "u"
196 /** \ingroup avr_inttypes
197  decimal printf format for uint_fast8_t */
198 #define PRIuFAST8 "u"
199 
200 /** \ingroup avr_inttypes
201  hexadecimal printf format for uint8_t */
202 #define PRIx8 "x"
203 /** \ingroup avr_inttypes
204  hexadecimal printf format for uint_least8_t */
205 #define PRIxLEAST8 "x"
206 /** \ingroup avr_inttypes
207  hexadecimal printf format for uint_fast8_t */
208 #define PRIxFAST8 "x"
209 
210 /** \ingroup avr_inttypes
211  uppercase hexadecimal printf format for uint8_t */
212 #define PRIX8 "X"
213 /** \ingroup avr_inttypes
214  uppercase hexadecimal printf format for uint_least8_t */
215 #define PRIXLEAST8 "X"
216 /** \ingroup avr_inttypes
217  uppercase hexadecimal printf format for uint_fast8_t */
218 #define PRIXFAST8 "X"
219 
220 
221 /** \ingroup avr_inttypes
222  octal printf format for uint16_t */
223 #define PRIo16 "o"
224 /** \ingroup avr_inttypes
225  octal printf format for uint_least16_t */
226 #define PRIoLEAST16 "o"
227 /** \ingroup avr_inttypes
228  octal printf format for uint_fast16_t */
229 #define PRIoFAST16 "o"
230 
231 /** \ingroup avr_inttypes
232  decimal printf format for uint16_t */
233 #define PRIu16 "u"
234 /** \ingroup avr_inttypes
235  decimal printf format for uint_least16_t */
236 #define PRIuLEAST16 "u"
237 /** \ingroup avr_inttypes
238  decimal printf format for uint_fast16_t */
239 #define PRIuFAST16 "u"
240 
241 /** \ingroup avr_inttypes
242  hexadecimal printf format for uint16_t */
243 #define PRIx16 "x"
244 /** \ingroup avr_inttypes
245  hexadecimal printf format for uint_least16_t */
246 #define PRIxLEAST16 "x"
247 /** \ingroup avr_inttypes
248  hexadecimal printf format for uint_fast16_t */
249 #define PRIxFAST16 "x"
250 
251 /** \ingroup avr_inttypes
252  uppercase hexadecimal printf format for uint16_t */
253 #define PRIX16 "X"
254 /** \ingroup avr_inttypes
255  uppercase hexadecimal printf format for uint_least16_t */
256 #define PRIXLEAST16 "X"
257 /** \ingroup avr_inttypes
258  uppercase hexadecimal printf format for uint_fast16_t */
259 #define PRIXFAST16 "X"
260 
261 
262 /** \ingroup avr_inttypes
263  octal printf format for uint32_t */
264 #define PRIo32 "lo"
265 /** \ingroup avr_inttypes
266  octal printf format for uint_least32_t */
267 #define PRIoLEAST32 "lo"
268 /** \ingroup avr_inttypes
269  octal printf format for uint_fast32_t */
270 #define PRIoFAST32 "lo"
271 
272 /** \ingroup avr_inttypes
273  decimal printf format for uint32_t */
274 #define PRIu32 "lu"
275 /** \ingroup avr_inttypes
276  decimal printf format for uint_least32_t */
277 #define PRIuLEAST32 "lu"
278 /** \ingroup avr_inttypes
279  decimal printf format for uint_fast32_t */
280 #define PRIuFAST32 "lu"
281 
282 /** \ingroup avr_inttypes
283  hexadecimal printf format for uint32_t */
284 #define PRIx32 "lx"
285 /** \ingroup avr_inttypes
286  hexadecimal printf format for uint_least32_t */
287 #define PRIxLEAST32 "lx"
288 /** \ingroup avr_inttypes
289  hexadecimal printf format for uint_fast32_t */
290 #define PRIxFAST32 "lx"
291 
292 /** \ingroup avr_inttypes
293  uppercase hexadecimal printf format for uint32_t */
294 #define PRIX32 "lX"
295 /** \ingroup avr_inttypes
296  uppercase hexadecimal printf format for uint_least32_t */
297 #define PRIXLEAST32 "lX"
298 /** \ingroup avr_inttypes
299  uppercase hexadecimal printf format for uint_fast32_t */
300 #define PRIXFAST32 "lX"
301 
302 
303 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
304 
305 #define PRIo64 "llo"
306 #define PRIoLEAST64 "llo"
307 #define PRIoFAST64 "llo"
308 
309 #define PRIu64 "llu"
310 #define PRIuLEAST64 "llu"
311 #define PRIuFAST64 "llu"
312 
313 #define PRIx64 "llx"
314 #define PRIxLEAST64 "llx"
315 #define PRIxFAST64 "llx"
316 
317 #define PRIX64 "llX"
318 #define PRIXLEAST64 "llX"
319 #define PRIXFAST64 "llX"
320 
321 #define PRIoMAX "llo"
322 #define PRIuMAX "llu"
323 #define PRIxMAX "llx"
324 #define PRIXMAX "llX"
325 
326 #endif
327 
328 /** \ingroup avr_inttypes
329  octal printf format for uintptr_t */
330 #define PRIoPTR PRIo16
331 /** \ingroup avr_inttypes
332  decimal printf format for uintptr_t */
333 #define PRIuPTR PRIu16
334 /** \ingroup avr_inttypes
335  hexadecimal printf format for uintptr_t */
336 #define PRIxPTR PRIx16
337 /** \ingroup avr_inttypes
338  uppercase hexadecimal printf format for uintptr_t */
339 #define PRIXPTR PRIX16
340 
341 
342 /** \ingroup avr_inttypes
343  decimal scanf format for int8_t */
344 #define SCNd8 "hhd"
345 /** \ingroup avr_inttypes
346  decimal scanf format for int_least8_t */
347 #define SCNdLEAST8 "hhd"
348 /** \ingroup avr_inttypes
349  decimal scanf format for int_fast8_t */
350 #define SCNdFAST8 "hhd"
351 
352 /** \ingroup avr_inttypes
353  generic-integer scanf format for int8_t */
354 #define SCNi8 "hhi"
355 /** \ingroup avr_inttypes
356  generic-integer scanf format for int_least8_t */
357 #define SCNiLEAST8 "hhi"
358 /** \ingroup avr_inttypes
359  generic-integer scanf format for int_fast8_t */
360 #define SCNiFAST8 "hhi"
361 
362 
363 /** \ingroup avr_inttypes
364  decimal scanf format for int16_t */
365 #define SCNd16 "d"
366 /** \ingroup avr_inttypes
367  decimal scanf format for int_least16_t */
368 #define SCNdLEAST16 "d"
369 /** \ingroup avr_inttypes
370  decimal scanf format for int_fast16_t */
371 #define SCNdFAST16 "d"
372 
373 /** \ingroup avr_inttypes
374  generic-integer scanf format for int16_t */
375 #define SCNi16 "i"
376 /** \ingroup avr_inttypes
377  generic-integer scanf format for int_least16_t */
378 #define SCNiLEAST16 "i"
379 /** \ingroup avr_inttypes
380  generic-integer scanf format for int_fast16_t */
381 #define SCNiFAST16 "i"
382 
383 
384 /** \ingroup avr_inttypes
385  decimal scanf format for int32_t */
386 #define SCNd32 "ld"
387 /** \ingroup avr_inttypes
388  decimal scanf format for int_least32_t */
389 #define SCNdLEAST32 "ld"
390 /** \ingroup avr_inttypes
391  decimal scanf format for int_fast32_t */
392 #define SCNdFAST32 "ld"
393 
394 /** \ingroup avr_inttypes
395  generic-integer scanf format for int32_t */
396 #define SCNi32 "li"
397 /** \ingroup avr_inttypes
398  generic-integer scanf format for int_least32_t */
399 #define SCNiLEAST32 "li"
400 /** \ingroup avr_inttypes
401  generic-integer scanf format for int_fast32_t */
402 #define SCNiFAST32 "li"
403 
404 
405 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
406 
407 #define SCNd64 "lld"
408 #define SCNdLEAST64 "lld"
409 #define SCNdFAST64 "lld"
410 
411 #define SCNi64 "lli"
412 #define SCNiLEAST64 "lli"
413 #define SCNiFAST64 "lli"
414 
415 #define SCNdMAX "lld"
416 #define SCNiMAX "lli"
417 
418 #endif
419 
420 /** \ingroup avr_inttypes
421  decimal scanf format for intptr_t */
422 #define SCNdPTR SCNd16
423 /** \ingroup avr_inttypes
424  generic-integer scanf format for intptr_t */
425 #define SCNiPTR SCNi16
426 
427 /** \ingroup avr_inttypes
428  octal scanf format for uint8_t */
429 #define SCNo8 "hho"
430 /** \ingroup avr_inttypes
431  octal scanf format for uint_least8_t */
432 #define SCNoLEAST8 "hho"
433 /** \ingroup avr_inttypes
434  octal scanf format for uint_fast8_t */
435 #define SCNoFAST8 "hho"
436 
437 /** \ingroup avr_inttypes
438  decimal scanf format for uint8_t */
439 #define SCNu8 "hhu"
440 /** \ingroup avr_inttypes
441  decimal scanf format for uint_least8_t */
442 #define SCNuLEAST8 "hhu"
443 /** \ingroup avr_inttypes
444  decimal scanf format for uint_fast8_t */
445 #define SCNuFAST8 "hhu"
446 
447 /** \ingroup avr_inttypes
448  hexadecimal scanf format for uint8_t */
449 #define SCNx8 "hhx"
450 /** \ingroup avr_inttypes
451  hexadecimal scanf format for uint_least8_t */
452 #define SCNxLEAST8 "hhx"
453 /** \ingroup avr_inttypes
454  hexadecimal scanf format for uint_fast8_t */
455 #define SCNxFAST8 "hhx"
456 
457 /** \ingroup avr_inttypes
458  octal scanf format for uint16_t */
459 #define SCNo16 "o"
460 /** \ingroup avr_inttypes
461  octal scanf format for uint_least16_t */
462 #define SCNoLEAST16 "o"
463 /** \ingroup avr_inttypes
464  octal scanf format for uint_fast16_t */
465 #define SCNoFAST16 "o"
466 
467 /** \ingroup avr_inttypes
468  decimal scanf format for uint16_t */
469 #define SCNu16 "u"
470 /** \ingroup avr_inttypes
471  decimal scanf format for uint_least16_t */
472 #define SCNuLEAST16 "u"
473 /** \ingroup avr_inttypes
474  decimal scanf format for uint_fast16_t */
475 #define SCNuFAST16 "u"
476 
477 /** \ingroup avr_inttypes
478  hexadecimal scanf format for uint16_t */
479 #define SCNx16 "x"
480 /** \ingroup avr_inttypes
481  hexadecimal scanf format for uint_least16_t */
482 #define SCNxLEAST16 "x"
483 /** \ingroup avr_inttypes
484  hexadecimal scanf format for uint_fast16_t */
485 #define SCNxFAST16 "x"
486 
487 
488 /** \ingroup avr_inttypes
489  octal scanf format for uint32_t */
490 #define SCNo32 "lo"
491 /** \ingroup avr_inttypes
492  octal scanf format for uint_least32_t */
493 #define SCNoLEAST32 "lo"
494 /** \ingroup avr_inttypes
495  octal scanf format for uint_fast32_t */
496 #define SCNoFAST32 "lo"
497 
498 /** \ingroup avr_inttypes
499  decimal scanf format for uint32_t */
500 #define SCNu32 "lu"
501 /** \ingroup avr_inttypes
502  decimal scanf format for uint_least32_t */
503 #define SCNuLEAST32 "lu"
504 /** \ingroup avr_inttypes
505  decimal scanf format for uint_fast32_t */
506 #define SCNuFAST32 "lu"
507 
508 /** \ingroup avr_inttypes
509  hexadecimal scanf format for uint32_t */
510 #define SCNx32 "lx"
511 /** \ingroup avr_inttypes
512  hexadecimal scanf format for uint_least32_t */
513 #define SCNxLEAST32 "lx"
514 /** \ingroup avr_inttypes
515  hexadecimal scanf format for uint_fast32_t */
516 #define SCNxFAST32 "lx"
517 
518 
519 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
520 
521 #define SCNo64 "llo"
522 #define SCNoLEAST64 "llo"
523 #define SCNoFAST64 "llo"
524 
525 #define SCNu64 "llu"
526 #define SCNuLEAST64 "llu"
527 #define SCNuFAST64 "llu"
528 
529 #define SCNx64 "llx"
530 #define SCNxLEAST64 "llx"
531 #define SCNxFAST64 "llx"
532 
533 #define SCNoMAX "llo"
534 #define SCNuMAX "llu"
535 #define SCNxMAX "llx"
536 
537 #endif
538 
539 /** \ingroup avr_inttypes
540  octal scanf format for uintptr_t */
541 #define SCNoPTR SCNo16
542 /** \ingroup avr_inttypes
543  decimal scanf format for uintptr_t */
544 #define SCNuPTR SCNu16
545 /** \ingroup avr_inttypes
546  hexadecimal scanf format for uintptr_t */
547 #define SCNxPTR SCNx16
548 
549 /*@}*/
550 
551 
552 #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
553 
554 
555 #endif /* __INTTYPES_H_ */
int32_t int_farptr_t
Definition: inttypes.h:77
signed long int int32_t
Definition: stdint.h:98
uint32_t uint_farptr_t
Definition: inttypes.h:81
unsigned long int uint32_t
Definition: stdint.h:103