AVR Libc Home Page |  | AVR Libc Development Pages
Main Page | User Manual | Library Reference | FAQ | Alphabetical Index | Example Projects

inttypes.h
Go to the documentation of this file.
1 /* Copyright (c) 2004,2005,2007 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.h 1766 2008-10-17 21:33:57Z arcanum $ */
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 */
77 typedef int32_t int_farptr_t;
78
79 /** \ingroup avr_inttypes
80 unsigned integer type that can hold a pointer > 64 KB */
81 typedef uint32_t uint_farptr_t;
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 #ifdef __avr_libc_does_not_implement_hh_in_scanf
343
344 #define SCNd8 "hhd"
345 #define SCNdLEAST8 "hhd"
346 #define SCNdFAST8 "hhd"
347
348 #define SCNi8 "hhi"
349 #define SCNiLEAST8 "hhi"
350 #define SCNiFAST8 "hhi"
351
352 #endif
353
354
355 /** \ingroup avr_inttypes
356 decimal scanf format for int16_t */
357 #define SCNd16 "d"
358 /** \ingroup avr_inttypes
359 decimal scanf format for int_least16_t */
360 #define SCNdLEAST16 "d"
361 /** \ingroup avr_inttypes
362 decimal scanf format for int_fast16_t */
363 #define SCNdFAST16 "d"
364
365 /** \ingroup avr_inttypes
366 generic-integer scanf format for int16_t */
367 #define SCNi16 "i"
368 /** \ingroup avr_inttypes
369 generic-integer scanf format for int_least16_t */
370 #define SCNiLEAST16 "i"
371 /** \ingroup avr_inttypes
372 generic-integer scanf format for int_fast16_t */
373 #define SCNiFAST16 "i"
374
375
376 /** \ingroup avr_inttypes
377 decimal scanf format for int32_t */
378 #define SCNd32 "ld"
379 /** \ingroup avr_inttypes
380 decimal scanf format for int_least32_t */
381 #define SCNdLEAST32 "ld"
382 /** \ingroup avr_inttypes
383 decimal scanf format for int_fast32_t */
384 #define SCNdFAST32 "ld"
385
386 /** \ingroup avr_inttypes
387 generic-integer scanf format for int32_t */
388 #define SCNi32 "li"
389 /** \ingroup avr_inttypes
390 generic-integer scanf format for int_least32_t */
391 #define SCNiLEAST32 "li"
392 /** \ingroup avr_inttypes
393 generic-integer scanf format for int_fast32_t */
394 #define SCNiFAST32 "li"
395
396
397 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
398
399 #define SCNd64 "lld"
400 #define SCNdLEAST64 "lld"
401 #define SCNdFAST64 "lld"
402
403 #define SCNi64 "lli"
404 #define SCNiLEAST64 "lli"
405 #define SCNiFAST64 "lli"
406
407 #define SCNdMAX "lld"
408 #define SCNiMAX "lli"
409
410 #endif
411
412 /** \ingroup avr_inttypes
413 decimal scanf format for intptr_t */
414 #define SCNdPTR SCNd16
415 /** \ingroup avr_inttypes
416 generic-integer scanf format for intptr_t */
417 #define SCNiPTR SCNi16
418
419 #ifdef __avr_libc_does_not_implement_hh_in_scanf
420
421 #define SCNo8 "hho"
422 #define SCNoLEAST8 "hho"
423 #define SCNoFAST8 "hho"
424
425 #define SCNu8 "hhu"
426 #define SCNuLEAST8 "hhu"
427 #define SCNuFAST8 "hhu"
428
429 #define SCNx8 "hhx"
430 #define SCNxLEAST8 "hhx"
431 #define SCNxFAST8 "hhx"
432
433 #endif
434
435 /** \ingroup avr_inttypes
436 octal scanf format for uint16_t */
437 #define SCNo16 "o"
438 /** \ingroup avr_inttypes
439 octal scanf format for uint_least16_t */
440 #define SCNoLEAST16 "o"
441 /** \ingroup avr_inttypes
442 octal scanf format for uint_fast16_t */
443 #define SCNoFAST16 "o"
444
445 /** \ingroup avr_inttypes
446 decimal scanf format for uint16_t */
447 #define SCNu16 "u"
448 /** \ingroup avr_inttypes
449 decimal scanf format for uint_least16_t */
450 #define SCNuLEAST16 "u"
451 /** \ingroup avr_inttypes
452 decimal scanf format for uint_fast16_t */
453 #define SCNuFAST16 "u"
454
455 /** \ingroup avr_inttypes
456 hexadecimal scanf format for uint16_t */
457 #define SCNx16 "x"
458 /** \ingroup avr_inttypes
459 hexadecimal scanf format for uint_least16_t */
460 #define SCNxLEAST16 "x"
461 /** \ingroup avr_inttypes
462 hexadecimal scanf format for uint_fast16_t */
463 #define SCNxFAST16 "x"
464
465
466 /** \ingroup avr_inttypes
467 octal scanf format for uint32_t */
468 #define SCNo32 "lo"
469 /** \ingroup avr_inttypes
470 octal scanf format for uint_least32_t */
471 #define SCNoLEAST32 "lo"
472 /** \ingroup avr_inttypes
473 octal scanf format for uint_fast32_t */
474 #define SCNoFAST32 "lo"
475
476 /** \ingroup avr_inttypes
477 decimal scanf format for uint32_t */
478 #define SCNu32 "lu"
479 /** \ingroup avr_inttypes
480 decimal scanf format for uint_least32_t */
481 #define SCNuLEAST32 "lu"
482 /** \ingroup avr_inttypes
483 decimal scanf format for uint_fast32_t */
484 #define SCNuFAST32 "lu"
485
486 /** \ingroup avr_inttypes
487 hexadecimal scanf format for uint32_t */
488 #define SCNx32 "lx"
489 /** \ingroup avr_inttypes
490 hexadecimal scanf format for uint_least32_t */
491 #define SCNxLEAST32 "lx"
492 /** \ingroup avr_inttypes
493 hexadecimal scanf format for uint_fast32_t */
494 #define SCNxFAST32 "lx"
495
496
497 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
498
499 #define SCNo64 "llo"
500 #define SCNoLEAST64 "llo"
501 #define SCNoFAST64 "llo"
502
503 #define SCNu64 "llu"
504 #define SCNuLEAST64 "llu"
505 #define SCNuFAST64 "llu"
506
507 #define SCNx64 "llx"
508 #define SCNxLEAST64 "llx"
509 #define SCNxFAST64 "llx"
510
511 #define SCNoMAX "llo"
512 #define SCNuMAX "llu"
513 #define SCNxMAX "llx"
514
515 #endif
516
517 /** \ingroup avr_inttypes
518 octal scanf format for uintptr_t */
519 #define SCNoPTR SCNo16
520 /** \ingroup avr_inttypes
521 decimal scanf format for uintptr_t */
522 #define SCNuPTR SCNu16
523 /** \ingroup avr_inttypes
524 hexadecimal scanf format for uintptr_t */
525 #define SCNxPTR SCNx16
526
527 /*@}*/
528
529
530 #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
531
532
533 #endif /* __INTTYPES_H_ */

Automatically generated by Doxygen 1.8.3.1 on Sun Sep 29 2013.