AVR-LibC  2.2.0
Standard C library for AVR-GCC
 

AVR-LibC Documentation

Logo

AVR-LibC Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

File List

Loading...
Searching...
No Matches
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$ */
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 KiB */
78
79/** \ingroup avr_inttypes
80 unsigned integer type that can hold a pointer > 64 KiB,
81 see also pgm_get_far_address()
82 */
84/**@}*/
85
86#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
87
88
89/** \name macros for printf and scanf format specifiers
90
91 For C++, these are only included if __STDC_LIMIT_MACROS
92 is defined before including <inttypes.h>.
93 */
94
95/**@{*/
96/** \ingroup avr_inttypes
97 decimal printf format for int8_t */
98#define PRId8 "d"
99/** \ingroup avr_inttypes
100 decimal printf format for int_least8_t */
101#define PRIdLEAST8 "d"
102/** \ingroup avr_inttypes
103 decimal printf format for int_fast8_t */
104#define PRIdFAST8 "d"
105
106/** \ingroup avr_inttypes
107 integer printf format for int8_t */
108#define PRIi8 "i"
109/** \ingroup avr_inttypes
110 integer printf format for int_least8_t */
111#define PRIiLEAST8 "i"
112/** \ingroup avr_inttypes
113 integer printf format for int_fast8_t */
114#define PRIiFAST8 "i"
115
116
117/** \ingroup avr_inttypes
118 decimal printf format for int16_t */
119#define PRId16 "d"
120/** \ingroup avr_inttypes
121 decimal printf format for int_least16_t */
122#define PRIdLEAST16 "d"
123/** \ingroup avr_inttypes
124 decimal printf format for int_fast16_t */
125#define PRIdFAST16 "d"
126
127/** \ingroup avr_inttypes
128 integer printf format for int16_t */
129#define PRIi16 "i"
130/** \ingroup avr_inttypes
131 integer printf format for int_least16_t */
132#define PRIiLEAST16 "i"
133/** \ingroup avr_inttypes
134 integer printf format for int_fast16_t */
135#define PRIiFAST16 "i"
136
137
138/** \ingroup avr_inttypes
139 decimal printf format for int32_t */
140#define PRId32 "ld"
141/** \ingroup avr_inttypes
142 decimal printf format for int_least32_t */
143#define PRIdLEAST32 "ld"
144/** \ingroup avr_inttypes
145 decimal printf format for int_fast32_t */
146#define PRIdFAST32 "ld"
147
148/** \ingroup avr_inttypes
149 integer printf format for int32_t */
150#define PRIi32 "li"
151/** \ingroup avr_inttypes
152 integer printf format for int_least32_t */
153#define PRIiLEAST32 "li"
154/** \ingroup avr_inttypes
155 integer printf format for int_fast32_t */
156#define PRIiFAST32 "li"
157
158
159#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
160
161#define PRId64 "lld"
162#define PRIdLEAST64 "lld"
163#define PRIdFAST64 "lld"
164
165#define PRIi64 "lli"
166#define PRIiLEAST64 "lli"
167#define PRIiFAST64 "lli"
168
169
170#define PRIdMAX "lld"
171#define PRIiMAX "lli"
172
173#endif
174
175/** \ingroup avr_inttypes
176 decimal printf format for intptr_t */
177#define PRIdPTR PRId16
178/** \ingroup avr_inttypes
179 integer printf format for intptr_t */
180#define PRIiPTR PRIi16
181
182/** \ingroup avr_inttypes
183 octal printf format for uint8_t */
184#define PRIo8 "o"
185/** \ingroup avr_inttypes
186 octal printf format for uint_least8_t */
187#define PRIoLEAST8 "o"
188/** \ingroup avr_inttypes
189 octal printf format for uint_fast8_t */
190#define PRIoFAST8 "o"
191
192/** \ingroup avr_inttypes
193 decimal printf format for uint8_t */
194#define PRIu8 "u"
195/** \ingroup avr_inttypes
196 decimal printf format for uint_least8_t */
197#define PRIuLEAST8 "u"
198/** \ingroup avr_inttypes
199 decimal printf format for uint_fast8_t */
200#define PRIuFAST8 "u"
201
202/** \ingroup avr_inttypes
203 hexadecimal printf format for uint8_t */
204#define PRIx8 "x"
205/** \ingroup avr_inttypes
206 hexadecimal printf format for uint_least8_t */
207#define PRIxLEAST8 "x"
208/** \ingroup avr_inttypes
209 hexadecimal printf format for uint_fast8_t */
210#define PRIxFAST8 "x"
211
212/** \ingroup avr_inttypes
213 uppercase hexadecimal printf format for uint8_t */
214#define PRIX8 "X"
215/** \ingroup avr_inttypes
216 uppercase hexadecimal printf format for uint_least8_t */
217#define PRIXLEAST8 "X"
218/** \ingroup avr_inttypes
219 uppercase hexadecimal printf format for uint_fast8_t */
220#define PRIXFAST8 "X"
221
222
223/** \ingroup avr_inttypes
224 octal printf format for uint16_t */
225#define PRIo16 "o"
226/** \ingroup avr_inttypes
227 octal printf format for uint_least16_t */
228#define PRIoLEAST16 "o"
229/** \ingroup avr_inttypes
230 octal printf format for uint_fast16_t */
231#define PRIoFAST16 "o"
232
233/** \ingroup avr_inttypes
234 decimal printf format for uint16_t */
235#define PRIu16 "u"
236/** \ingroup avr_inttypes
237 decimal printf format for uint_least16_t */
238#define PRIuLEAST16 "u"
239/** \ingroup avr_inttypes
240 decimal printf format for uint_fast16_t */
241#define PRIuFAST16 "u"
242
243/** \ingroup avr_inttypes
244 hexadecimal printf format for uint16_t */
245#define PRIx16 "x"
246/** \ingroup avr_inttypes
247 hexadecimal printf format for uint_least16_t */
248#define PRIxLEAST16 "x"
249/** \ingroup avr_inttypes
250 hexadecimal printf format for uint_fast16_t */
251#define PRIxFAST16 "x"
252
253/** \ingroup avr_inttypes
254 uppercase hexadecimal printf format for uint16_t */
255#define PRIX16 "X"
256/** \ingroup avr_inttypes
257 uppercase hexadecimal printf format for uint_least16_t */
258#define PRIXLEAST16 "X"
259/** \ingroup avr_inttypes
260 uppercase hexadecimal printf format for uint_fast16_t */
261#define PRIXFAST16 "X"
262
263
264/** \ingroup avr_inttypes
265 octal printf format for uint32_t */
266#define PRIo32 "lo"
267/** \ingroup avr_inttypes
268 octal printf format for uint_least32_t */
269#define PRIoLEAST32 "lo"
270/** \ingroup avr_inttypes
271 octal printf format for uint_fast32_t */
272#define PRIoFAST32 "lo"
273
274/** \ingroup avr_inttypes
275 decimal printf format for uint32_t */
276#define PRIu32 "lu"
277/** \ingroup avr_inttypes
278 decimal printf format for uint_least32_t */
279#define PRIuLEAST32 "lu"
280/** \ingroup avr_inttypes
281 decimal printf format for uint_fast32_t */
282#define PRIuFAST32 "lu"
283
284/** \ingroup avr_inttypes
285 hexadecimal printf format for uint32_t */
286#define PRIx32 "lx"
287/** \ingroup avr_inttypes
288 hexadecimal printf format for uint_least32_t */
289#define PRIxLEAST32 "lx"
290/** \ingroup avr_inttypes
291 hexadecimal printf format for uint_fast32_t */
292#define PRIxFAST32 "lx"
293
294/** \ingroup avr_inttypes
295 uppercase hexadecimal printf format for uint32_t */
296#define PRIX32 "lX"
297/** \ingroup avr_inttypes
298 uppercase hexadecimal printf format for uint_least32_t */
299#define PRIXLEAST32 "lX"
300/** \ingroup avr_inttypes
301 uppercase hexadecimal printf format for uint_fast32_t */
302#define PRIXFAST32 "lX"
303
304
305#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
306
307#define PRIo64 "llo"
308#define PRIoLEAST64 "llo"
309#define PRIoFAST64 "llo"
310
311#define PRIu64 "llu"
312#define PRIuLEAST64 "llu"
313#define PRIuFAST64 "llu"
314
315#define PRIx64 "llx"
316#define PRIxLEAST64 "llx"
317#define PRIxFAST64 "llx"
318
319#define PRIX64 "llX"
320#define PRIXLEAST64 "llX"
321#define PRIXFAST64 "llX"
322
323#define PRIoMAX "llo"
324#define PRIuMAX "llu"
325#define PRIxMAX "llx"
326#define PRIXMAX "llX"
327
328#endif
329
330/** \ingroup avr_inttypes
331 octal printf format for uintptr_t */
332#define PRIoPTR PRIo16
333/** \ingroup avr_inttypes
334 decimal printf format for uintptr_t */
335#define PRIuPTR PRIu16
336/** \ingroup avr_inttypes
337 hexadecimal printf format for uintptr_t */
338#define PRIxPTR PRIx16
339/** \ingroup avr_inttypes
340 uppercase hexadecimal printf format for uintptr_t */
341#define PRIXPTR PRIX16
342
343
344/** \ingroup avr_inttypes
345 decimal scanf format for int8_t */
346#define SCNd8 "hhd"
347/** \ingroup avr_inttypes
348 decimal scanf format for int_least8_t */
349#define SCNdLEAST8 "hhd"
350/** \ingroup avr_inttypes
351 decimal scanf format for int_fast8_t */
352#define SCNdFAST8 "hhd"
353
354/** \ingroup avr_inttypes
355 generic-integer scanf format for int8_t */
356#define SCNi8 "hhi"
357/** \ingroup avr_inttypes
358 generic-integer scanf format for int_least8_t */
359#define SCNiLEAST8 "hhi"
360/** \ingroup avr_inttypes
361 generic-integer scanf format for int_fast8_t */
362#define SCNiFAST8 "hhi"
363
364
365/** \ingroup avr_inttypes
366 decimal scanf format for int16_t */
367#define SCNd16 "d"
368/** \ingroup avr_inttypes
369 decimal scanf format for int_least16_t */
370#define SCNdLEAST16 "d"
371/** \ingroup avr_inttypes
372 decimal scanf format for int_fast16_t */
373#define SCNdFAST16 "d"
374
375/** \ingroup avr_inttypes
376 generic-integer scanf format for int16_t */
377#define SCNi16 "i"
378/** \ingroup avr_inttypes
379 generic-integer scanf format for int_least16_t */
380#define SCNiLEAST16 "i"
381/** \ingroup avr_inttypes
382 generic-integer scanf format for int_fast16_t */
383#define SCNiFAST16 "i"
384
385
386/** \ingroup avr_inttypes
387 decimal scanf format for int32_t */
388#define SCNd32 "ld"
389/** \ingroup avr_inttypes
390 decimal scanf format for int_least32_t */
391#define SCNdLEAST32 "ld"
392/** \ingroup avr_inttypes
393 decimal scanf format for int_fast32_t */
394#define SCNdFAST32 "ld"
395
396/** \ingroup avr_inttypes
397 generic-integer scanf format for int32_t */
398#define SCNi32 "li"
399/** \ingroup avr_inttypes
400 generic-integer scanf format for int_least32_t */
401#define SCNiLEAST32 "li"
402/** \ingroup avr_inttypes
403 generic-integer scanf format for int_fast32_t */
404#define SCNiFAST32 "li"
405
406
407#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
408
409#define SCNd64 "lld"
410#define SCNdLEAST64 "lld"
411#define SCNdFAST64 "lld"
412
413#define SCNi64 "lli"
414#define SCNiLEAST64 "lli"
415#define SCNiFAST64 "lli"
416
417#define SCNdMAX "lld"
418#define SCNiMAX "lli"
419
420#endif
421
422/** \ingroup avr_inttypes
423 decimal scanf format for intptr_t */
424#define SCNdPTR SCNd16
425/** \ingroup avr_inttypes
426 generic-integer scanf format for intptr_t */
427#define SCNiPTR SCNi16
428
429/** \ingroup avr_inttypes
430 octal scanf format for uint8_t */
431#define SCNo8 "hho"
432/** \ingroup avr_inttypes
433 octal scanf format for uint_least8_t */
434#define SCNoLEAST8 "hho"
435/** \ingroup avr_inttypes
436 octal scanf format for uint_fast8_t */
437#define SCNoFAST8 "hho"
438
439/** \ingroup avr_inttypes
440 decimal scanf format for uint8_t */
441#define SCNu8 "hhu"
442/** \ingroup avr_inttypes
443 decimal scanf format for uint_least8_t */
444#define SCNuLEAST8 "hhu"
445/** \ingroup avr_inttypes
446 decimal scanf format for uint_fast8_t */
447#define SCNuFAST8 "hhu"
448
449/** \ingroup avr_inttypes
450 hexadecimal scanf format for uint8_t */
451#define SCNx8 "hhx"
452/** \ingroup avr_inttypes
453 hexadecimal scanf format for uint_least8_t */
454#define SCNxLEAST8 "hhx"
455/** \ingroup avr_inttypes
456 hexadecimal scanf format for uint_fast8_t */
457#define SCNxFAST8 "hhx"
458
459/** \ingroup avr_inttypes
460 octal scanf format for uint16_t */
461#define SCNo16 "o"
462/** \ingroup avr_inttypes
463 octal scanf format for uint_least16_t */
464#define SCNoLEAST16 "o"
465/** \ingroup avr_inttypes
466 octal scanf format for uint_fast16_t */
467#define SCNoFAST16 "o"
468
469/** \ingroup avr_inttypes
470 decimal scanf format for uint16_t */
471#define SCNu16 "u"
472/** \ingroup avr_inttypes
473 decimal scanf format for uint_least16_t */
474#define SCNuLEAST16 "u"
475/** \ingroup avr_inttypes
476 decimal scanf format for uint_fast16_t */
477#define SCNuFAST16 "u"
478
479/** \ingroup avr_inttypes
480 hexadecimal scanf format for uint16_t */
481#define SCNx16 "x"
482/** \ingroup avr_inttypes
483 hexadecimal scanf format for uint_least16_t */
484#define SCNxLEAST16 "x"
485/** \ingroup avr_inttypes
486 hexadecimal scanf format for uint_fast16_t */
487#define SCNxFAST16 "x"
488
489
490/** \ingroup avr_inttypes
491 octal scanf format for uint32_t */
492#define SCNo32 "lo"
493/** \ingroup avr_inttypes
494 octal scanf format for uint_least32_t */
495#define SCNoLEAST32 "lo"
496/** \ingroup avr_inttypes
497 octal scanf format for uint_fast32_t */
498#define SCNoFAST32 "lo"
499
500/** \ingroup avr_inttypes
501 decimal scanf format for uint32_t */
502#define SCNu32 "lu"
503/** \ingroup avr_inttypes
504 decimal scanf format for uint_least32_t */
505#define SCNuLEAST32 "lu"
506/** \ingroup avr_inttypes
507 decimal scanf format for uint_fast32_t */
508#define SCNuFAST32 "lu"
509
510/** \ingroup avr_inttypes
511 hexadecimal scanf format for uint32_t */
512#define SCNx32 "lx"
513/** \ingroup avr_inttypes
514 hexadecimal scanf format for uint_least32_t */
515#define SCNxLEAST32 "lx"
516/** \ingroup avr_inttypes
517 hexadecimal scanf format for uint_fast32_t */
518#define SCNxFAST32 "lx"
519
520
521#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
522
523#define SCNo64 "llo"
524#define SCNoLEAST64 "llo"
525#define SCNoFAST64 "llo"
526
527#define SCNu64 "llu"
528#define SCNuLEAST64 "llu"
529#define SCNuFAST64 "llu"
530
531#define SCNx64 "llx"
532#define SCNxLEAST64 "llx"
533#define SCNxFAST64 "llx"
534
535#define SCNoMAX "llo"
536#define SCNuMAX "llu"
537#define SCNxMAX "llx"
538
539#endif
540
541/** \ingroup avr_inttypes
542 octal scanf format for uintptr_t */
543#define SCNoPTR SCNo16
544/** \ingroup avr_inttypes
545 decimal scanf format for uintptr_t */
546#define SCNuPTR SCNu16
547/** \ingroup avr_inttypes
548 hexadecimal scanf format for uintptr_t */
549#define SCNxPTR SCNx16
550
551/**@}*/
552
553
554#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
555
556
557#endif /* __INTTYPES_H_ */
int32_t int_farptr_t
Definition: inttypes.h:77
uint32_t uint_farptr_t
Definition: inttypes.h:83
unsigned long int uint32_t
Definition: stdint.h:103
signed long int int32_t
Definition: stdint.h:98