1
/* Copyright (c) 2004,2005,2007 Joerg Wunsch
2
Copyright (c) 2005, Carlos Lamas
5
Redistribution and use in source and binary forms, with or without
6
modification, are permitted provided that the following conditions are met:
8
* Redistributions of source code must retain the above copyright
9
notice, this list of conditions and the following disclaimer.
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
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.
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. */
32
/* $Id: inttypes.h 1766 2008-10-17 21:33:57Z arcanum $ */
40
/** \defgroup avr_inttypes <inttypes.h>: Integer Type conversions
41
\code #include <inttypes.h> \endcode
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.
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.
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()
66
printf("The hexadecimal value of smallval is %" PRIx8
67
", the decimal value of longval is %" PRId32 ".\n",
72
/** \name Far pointers for memory access >64K */
75
/** \ingroup avr_inttypes
76
signed integer type that can hold a pointer > 64 KB */
77
typedef int32_t int_farptr_t;
79
/** \ingroup avr_inttypes
80
unsigned integer type that can hold a pointer > 64 KB */
81
typedef uint32_t uint_farptr_t;
84
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
87
/** \name macros for printf and scanf format specifiers
89
For C++, these are only included if __STDC_LIMIT_MACROS
90
is defined before including <inttypes.h>.
94
/** \ingroup avr_inttypes
95
decimal printf format for int8_t */
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"
104
/** \ingroup avr_inttypes
105
integer printf format for int8_t */
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"
115
/** \ingroup avr_inttypes
116
decimal printf format for int16_t */
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"
125
/** \ingroup avr_inttypes
126
integer printf format for int16_t */
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"
136
/** \ingroup avr_inttypes
137
decimal printf format for int32_t */
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"
146
/** \ingroup avr_inttypes
147
integer printf format for int32_t */
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"
157
#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
160
#define PRIdLEAST64 "lld"
161
#define PRIdFAST64 "lld"
164
#define PRIiLEAST64 "lli"
165
#define PRIiFAST64 "lli"
168
#define PRIdMAX "lld"
169
#define PRIiMAX "lli"
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
180
/** \ingroup avr_inttypes
181
octal printf format for uint8_t */
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"
190
/** \ingroup avr_inttypes
191
decimal printf format for uint8_t */
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"
200
/** \ingroup avr_inttypes
201
hexadecimal printf format for uint8_t */
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"
210
/** \ingroup avr_inttypes
211
uppercase hexadecimal printf format for uint8_t */
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"
221
/** \ingroup avr_inttypes
222
octal printf format for uint16_t */
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"
231
/** \ingroup avr_inttypes
232
decimal printf format for uint16_t */
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"
241
/** \ingroup avr_inttypes
242
hexadecimal printf format for uint16_t */
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"
251
/** \ingroup avr_inttypes
252
uppercase hexadecimal printf format for uint16_t */
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"
262
/** \ingroup avr_inttypes
263
octal printf format for uint32_t */
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"
272
/** \ingroup avr_inttypes
273
decimal printf format for uint32_t */
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"
282
/** \ingroup avr_inttypes
283
hexadecimal printf format for uint32_t */
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"
292
/** \ingroup avr_inttypes
293
uppercase hexadecimal printf format for uint32_t */
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"
303
#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
306
#define PRIoLEAST64 "llo"
307
#define PRIoFAST64 "llo"
310
#define PRIuLEAST64 "llu"
311
#define PRIuFAST64 "llu"
314
#define PRIxLEAST64 "llx"
315
#define PRIxFAST64 "llx"
318
#define PRIXLEAST64 "llX"
319
#define PRIXFAST64 "llX"
321
#define PRIoMAX "llo"
322
#define PRIuMAX "llu"
323
#define PRIxMAX "llx"
324
#define PRIXMAX "llX"
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
342
#ifdef __avr_libc_does_not_implement_hh_in_scanf
345
#define SCNdLEAST8 "hhd"
346
#define SCNdFAST8 "hhd"
349
#define SCNiLEAST8 "hhi"
350
#define SCNiFAST8 "hhi"
355
/** \ingroup avr_inttypes
356
decimal scanf format for int16_t */
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"
365
/** \ingroup avr_inttypes
366
generic-integer scanf format for int16_t */
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"
376
/** \ingroup avr_inttypes
377
decimal scanf format for int32_t */
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"
386
/** \ingroup avr_inttypes
387
generic-integer scanf format for int32_t */
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"
397
#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
400
#define SCNdLEAST64 "lld"
401
#define SCNdFAST64 "lld"
404
#define SCNiLEAST64 "lli"
405
#define SCNiFAST64 "lli"
407
#define SCNdMAX "lld"
408
#define SCNiMAX "lli"
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
419
#ifdef __avr_libc_does_not_implement_hh_in_scanf
422
#define SCNoLEAST8 "hho"
423
#define SCNoFAST8 "hho"
426
#define SCNuLEAST8 "hhu"
427
#define SCNuFAST8 "hhu"
430
#define SCNxLEAST8 "hhx"
431
#define SCNxFAST8 "hhx"
435
/** \ingroup avr_inttypes
436
octal scanf format for uint16_t */
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"
445
/** \ingroup avr_inttypes
446
decimal scanf format for uint16_t */
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"
455
/** \ingroup avr_inttypes
456
hexadecimal scanf format for uint16_t */
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"
466
/** \ingroup avr_inttypes
467
octal scanf format for uint32_t */
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"
476
/** \ingroup avr_inttypes
477
decimal scanf format for uint32_t */
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"
486
/** \ingroup avr_inttypes
487
hexadecimal scanf format for uint32_t */
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"
497
#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
500
#define SCNoLEAST64 "llo"
501
#define SCNoFAST64 "llo"
504
#define SCNuLEAST64 "llu"
505
#define SCNuFAST64 "llu"
508
#define SCNxLEAST64 "llx"
509
#define SCNxFAST64 "llx"
511
#define SCNoMAX "llo"
512
#define SCNuMAX "llu"
513
#define SCNxMAX "llx"
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
530
#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
533
#endif /* __INTTYPES_H_ */