$extrastylesheet
avr-libc  2.0.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.
00001 /* Copyright (c) 2004,2005,2007,2012 Joerg Wunsch
00002    Copyright (c) 2005, Carlos Lamas
00003    All rights reserved.
00004 
00005    Redistribution and use in source and binary forms, with or without
00006    modification, are permitted provided that the following conditions are met:
00007 
00008    * Redistributions of source code must retain the above copyright
00009      notice, this list of conditions and the following disclaimer.
00010 
00011    * Redistributions in binary form must reproduce the above copyright
00012      notice, this list of conditions and the following disclaimer in
00013      the documentation and/or other materials provided with the
00014      distribution.
00015 
00016    * Neither the name of the copyright holders nor the names of
00017      contributors may be used to endorse or promote products derived
00018      from this software without specific prior written permission.
00019 
00020   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00021   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00024   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00025   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00026   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00029   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030   POSSIBILITY OF SUCH DAMAGE. */
00031 
00032 /* $Id: inttypes.h 2302 2012-11-26 10:52:01Z joerg_wunsch $ */
00033 
00034 #ifndef __INTTYPES_H_
00035 #define __INTTYPES_H_
00036 
00037 #include <stdint.h>
00038 
00039 /** \file */
00040 /** \defgroup avr_inttypes <inttypes.h>: Integer Type conversions
00041     \code #include <inttypes.h> \endcode
00042 
00043     This header file includes the exact-width integer definitions from
00044     <tt><stdint.h></tt>, and extends them with additional facilities
00045     provided by the implementation.
00046 
00047     Currently, the extensions include two additional integer types
00048     that could hold a "far" pointer (i.e. a code pointer that can
00049     address more than 64 KB), as well as standard names for all printf
00050     and scanf formatting options that are supported by the \ref avr_stdio.
00051     As the library does not support the full range of conversion
00052     specifiers from ISO 9899:1999, only those conversions that are
00053     actually implemented will be listed here.
00054 
00055     The idea behind these conversion macros is that, for each of the
00056     types defined by <stdint.h>, a macro will be supplied that portably
00057     allows formatting an object of that type in printf() or scanf()
00058     operations.  Example:
00059 
00060     \code
00061     #include <inttypes.h>
00062 
00063     uint8_t smallval;
00064     int32_t longval;
00065     ...
00066     printf("The hexadecimal value of smallval is %" PRIx8
00067            ", the decimal value of longval is %" PRId32 ".\n",
00068        smallval, longval);
00069     \endcode
00070 */
00071 
00072 /** \name Far pointers for memory access >64K */
00073 
00074 /*@{*/
00075 /** \ingroup avr_inttypes
00076     signed integer type that can hold a pointer > 64 KB */
00077 typedef int32_t int_farptr_t;
00078 
00079 /** \ingroup avr_inttypes
00080     unsigned integer type that can hold a pointer > 64 KB */
00081 typedef uint32_t uint_farptr_t;
00082 /*@}*/
00083 
00084 #if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
00085 
00086 
00087 /** \name macros for printf and scanf format specifiers
00088 
00089     For C++, these are only included if __STDC_LIMIT_MACROS
00090     is defined before including <inttypes.h>.
00091  */
00092 
00093 /*@{*/
00094 /** \ingroup avr_inttypes
00095     decimal printf format for int8_t */
00096 #define     PRId8           "d"
00097 /** \ingroup avr_inttypes
00098     decimal printf format for int_least8_t */
00099 #define     PRIdLEAST8      "d"
00100 /** \ingroup avr_inttypes
00101     decimal printf format for int_fast8_t */
00102 #define     PRIdFAST8       "d"
00103 
00104 /** \ingroup avr_inttypes
00105     integer printf format for int8_t */
00106 #define     PRIi8           "i"
00107 /** \ingroup avr_inttypes
00108     integer printf format for int_least8_t */
00109 #define     PRIiLEAST8      "i"
00110 /** \ingroup avr_inttypes
00111     integer printf format for int_fast8_t */
00112 #define     PRIiFAST8       "i"
00113 
00114 
00115 /** \ingroup avr_inttypes
00116     decimal printf format for int16_t */
00117 #define     PRId16          "d"
00118 /** \ingroup avr_inttypes
00119     decimal printf format for int_least16_t */
00120 #define     PRIdLEAST16     "d"
00121 /** \ingroup avr_inttypes
00122     decimal printf format for int_fast16_t */
00123 #define     PRIdFAST16      "d"
00124 
00125 /** \ingroup avr_inttypes
00126     integer printf format for int16_t */
00127 #define     PRIi16          "i"
00128 /** \ingroup avr_inttypes
00129     integer printf format for int_least16_t */
00130 #define     PRIiLEAST16     "i"
00131 /** \ingroup avr_inttypes
00132     integer printf format for int_fast16_t */
00133 #define     PRIiFAST16      "i"
00134 
00135 
00136 /** \ingroup avr_inttypes
00137     decimal printf format for int32_t */
00138 #define     PRId32          "ld"
00139 /** \ingroup avr_inttypes
00140     decimal printf format for int_least32_t */
00141 #define     PRIdLEAST32     "ld"
00142 /** \ingroup avr_inttypes
00143     decimal printf format for int_fast32_t */
00144 #define     PRIdFAST32      "ld"
00145 
00146 /** \ingroup avr_inttypes
00147     integer printf format for int32_t */
00148 #define     PRIi32          "li"
00149 /** \ingroup avr_inttypes
00150     integer printf format for int_least32_t */
00151 #define     PRIiLEAST32     "li"
00152 /** \ingroup avr_inttypes
00153     integer printf format for int_fast32_t */
00154 #define     PRIiFAST32      "li"
00155 
00156 
00157 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
00158 
00159 #define     PRId64          "lld"
00160 #define     PRIdLEAST64     "lld"
00161 #define     PRIdFAST64      "lld"
00162 
00163 #define     PRIi64          "lli"
00164 #define     PRIiLEAST64     "lli"
00165 #define     PRIiFAST64      "lli"
00166 
00167 
00168 #define     PRIdMAX         "lld"
00169 #define     PRIiMAX         "lli"
00170 
00171 #endif
00172 
00173 /** \ingroup avr_inttypes
00174     decimal printf format for intptr_t */
00175 #define     PRIdPTR         PRId16
00176 /** \ingroup avr_inttypes
00177     integer printf format for intptr_t */
00178 #define     PRIiPTR         PRIi16
00179 
00180 /** \ingroup avr_inttypes
00181     octal printf format for uint8_t */
00182 #define     PRIo8           "o"
00183 /** \ingroup avr_inttypes
00184     octal printf format for uint_least8_t */
00185 #define     PRIoLEAST8      "o"
00186 /** \ingroup avr_inttypes
00187     octal printf format for uint_fast8_t */
00188 #define     PRIoFAST8       "o"
00189 
00190 /** \ingroup avr_inttypes
00191     decimal printf format for uint8_t */
00192 #define     PRIu8           "u"
00193 /** \ingroup avr_inttypes
00194     decimal printf format for uint_least8_t */
00195 #define     PRIuLEAST8      "u"
00196 /** \ingroup avr_inttypes
00197     decimal printf format for uint_fast8_t */
00198 #define     PRIuFAST8       "u"
00199 
00200 /** \ingroup avr_inttypes
00201     hexadecimal printf format for uint8_t */
00202 #define     PRIx8           "x"
00203 /** \ingroup avr_inttypes
00204     hexadecimal printf format for uint_least8_t */
00205 #define     PRIxLEAST8      "x"
00206 /** \ingroup avr_inttypes
00207     hexadecimal printf format for uint_fast8_t */
00208 #define     PRIxFAST8       "x"
00209 
00210 /** \ingroup avr_inttypes
00211     uppercase hexadecimal printf format for uint8_t */
00212 #define     PRIX8           "X"
00213 /** \ingroup avr_inttypes
00214     uppercase hexadecimal printf format for uint_least8_t */
00215 #define     PRIXLEAST8      "X"
00216 /** \ingroup avr_inttypes
00217     uppercase hexadecimal printf format for uint_fast8_t */
00218 #define     PRIXFAST8       "X"
00219 
00220 
00221 /** \ingroup avr_inttypes
00222     octal printf format for uint16_t */
00223 #define     PRIo16          "o"
00224 /** \ingroup avr_inttypes
00225     octal printf format for uint_least16_t */
00226 #define     PRIoLEAST16     "o"
00227 /** \ingroup avr_inttypes
00228     octal printf format for uint_fast16_t */
00229 #define     PRIoFAST16      "o"
00230 
00231 /** \ingroup avr_inttypes
00232     decimal printf format for uint16_t */
00233 #define     PRIu16          "u"
00234 /** \ingroup avr_inttypes
00235     decimal printf format for uint_least16_t */
00236 #define     PRIuLEAST16     "u"
00237 /** \ingroup avr_inttypes
00238     decimal printf format for uint_fast16_t */
00239 #define     PRIuFAST16      "u"
00240 
00241 /** \ingroup avr_inttypes
00242     hexadecimal printf format for uint16_t */
00243 #define     PRIx16          "x"
00244 /** \ingroup avr_inttypes
00245     hexadecimal printf format for uint_least16_t */
00246 #define     PRIxLEAST16     "x"
00247 /** \ingroup avr_inttypes
00248     hexadecimal printf format for uint_fast16_t */
00249 #define     PRIxFAST16      "x"
00250 
00251 /** \ingroup avr_inttypes
00252     uppercase hexadecimal printf format for uint16_t */
00253 #define     PRIX16          "X"
00254 /** \ingroup avr_inttypes
00255     uppercase hexadecimal printf format for uint_least16_t */
00256 #define     PRIXLEAST16     "X"
00257 /** \ingroup avr_inttypes
00258     uppercase hexadecimal printf format for uint_fast16_t */
00259 #define     PRIXFAST16      "X"
00260 
00261 
00262 /** \ingroup avr_inttypes
00263     octal printf format for uint32_t */
00264 #define     PRIo32          "lo"
00265 /** \ingroup avr_inttypes
00266     octal printf format for uint_least32_t */
00267 #define     PRIoLEAST32     "lo"
00268 /** \ingroup avr_inttypes
00269     octal printf format for uint_fast32_t */
00270 #define     PRIoFAST32      "lo"
00271 
00272 /** \ingroup avr_inttypes
00273     decimal printf format for uint32_t */
00274 #define     PRIu32          "lu"
00275 /** \ingroup avr_inttypes
00276     decimal printf format for uint_least32_t */
00277 #define     PRIuLEAST32     "lu"
00278 /** \ingroup avr_inttypes
00279     decimal printf format for uint_fast32_t */
00280 #define     PRIuFAST32      "lu"
00281 
00282 /** \ingroup avr_inttypes
00283     hexadecimal printf format for uint32_t */
00284 #define     PRIx32          "lx"
00285 /** \ingroup avr_inttypes
00286     hexadecimal printf format for uint_least32_t */
00287 #define     PRIxLEAST32     "lx"
00288 /** \ingroup avr_inttypes
00289     hexadecimal printf format for uint_fast32_t */
00290 #define     PRIxFAST32      "lx"
00291 
00292 /** \ingroup avr_inttypes
00293     uppercase hexadecimal printf format for uint32_t */
00294 #define     PRIX32          "lX"
00295 /** \ingroup avr_inttypes
00296     uppercase hexadecimal printf format for uint_least32_t */
00297 #define     PRIXLEAST32     "lX"
00298 /** \ingroup avr_inttypes
00299     uppercase hexadecimal printf format for uint_fast32_t */
00300 #define     PRIXFAST32      "lX"
00301 
00302 
00303 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
00304 
00305 #define     PRIo64          "llo"
00306 #define     PRIoLEAST64     "llo"
00307 #define     PRIoFAST64      "llo"
00308 
00309 #define     PRIu64          "llu"
00310 #define     PRIuLEAST64     "llu"
00311 #define     PRIuFAST64      "llu"
00312 
00313 #define     PRIx64          "llx"
00314 #define     PRIxLEAST64     "llx"
00315 #define     PRIxFAST64      "llx"
00316 
00317 #define     PRIX64          "llX"
00318 #define     PRIXLEAST64     "llX"
00319 #define     PRIXFAST64      "llX"
00320 
00321 #define     PRIoMAX         "llo"
00322 #define     PRIuMAX         "llu"
00323 #define     PRIxMAX         "llx"
00324 #define     PRIXMAX         "llX"
00325 
00326 #endif
00327 
00328 /** \ingroup avr_inttypes
00329     octal printf format for uintptr_t */
00330 #define     PRIoPTR         PRIo16
00331 /** \ingroup avr_inttypes
00332     decimal printf format for uintptr_t */
00333 #define     PRIuPTR         PRIu16
00334 /** \ingroup avr_inttypes
00335     hexadecimal printf format for uintptr_t */
00336 #define     PRIxPTR         PRIx16
00337 /** \ingroup avr_inttypes
00338     uppercase hexadecimal printf format for uintptr_t */
00339 #define     PRIXPTR         PRIX16
00340 
00341 
00342 /** \ingroup avr_inttypes
00343     decimal scanf format for int8_t */
00344 #define     SCNd8           "hhd"
00345 /** \ingroup avr_inttypes
00346     decimal scanf format for int_least8_t */
00347 #define     SCNdLEAST8      "hhd"
00348 /** \ingroup avr_inttypes
00349     decimal scanf format for int_fast8_t */
00350 #define     SCNdFAST8       "hhd"
00351 
00352 /** \ingroup avr_inttypes
00353     generic-integer scanf format for int8_t */
00354 #define     SCNi8           "hhi"
00355 /** \ingroup avr_inttypes
00356     generic-integer scanf format for int_least8_t */
00357 #define     SCNiLEAST8      "hhi"
00358 /** \ingroup avr_inttypes
00359     generic-integer scanf format for int_fast8_t */
00360 #define     SCNiFAST8       "hhi"
00361 
00362 
00363 /** \ingroup avr_inttypes
00364     decimal scanf format for int16_t */
00365 #define     SCNd16          "d"
00366 /** \ingroup avr_inttypes
00367     decimal scanf format for int_least16_t */
00368 #define     SCNdLEAST16     "d"
00369 /** \ingroup avr_inttypes
00370     decimal scanf format for int_fast16_t */
00371 #define     SCNdFAST16      "d"
00372 
00373 /** \ingroup avr_inttypes
00374     generic-integer scanf format for int16_t */
00375 #define     SCNi16          "i"
00376 /** \ingroup avr_inttypes
00377     generic-integer scanf format for int_least16_t */
00378 #define     SCNiLEAST16     "i"
00379 /** \ingroup avr_inttypes
00380     generic-integer scanf format for int_fast16_t */
00381 #define     SCNiFAST16      "i"
00382 
00383 
00384 /** \ingroup avr_inttypes
00385     decimal scanf format for int32_t */
00386 #define     SCNd32          "ld"
00387 /** \ingroup avr_inttypes
00388     decimal scanf format for int_least32_t */
00389 #define     SCNdLEAST32     "ld"
00390 /** \ingroup avr_inttypes
00391     decimal scanf format for int_fast32_t */
00392 #define     SCNdFAST32      "ld"
00393 
00394 /** \ingroup avr_inttypes
00395     generic-integer scanf format for int32_t */
00396 #define     SCNi32          "li"
00397 /** \ingroup avr_inttypes
00398     generic-integer scanf format for int_least32_t */
00399 #define     SCNiLEAST32     "li"
00400 /** \ingroup avr_inttypes
00401     generic-integer scanf format for int_fast32_t */
00402 #define     SCNiFAST32      "li"
00403 
00404 
00405 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
00406 
00407 #define     SCNd64          "lld"
00408 #define     SCNdLEAST64     "lld"
00409 #define     SCNdFAST64      "lld"
00410 
00411 #define     SCNi64          "lli"
00412 #define     SCNiLEAST64     "lli"
00413 #define     SCNiFAST64      "lli"
00414 
00415 #define     SCNdMAX         "lld"
00416 #define     SCNiMAX         "lli"
00417 
00418 #endif
00419 
00420 /** \ingroup avr_inttypes
00421     decimal scanf format for intptr_t */
00422 #define     SCNdPTR         SCNd16
00423 /** \ingroup avr_inttypes
00424     generic-integer scanf format for intptr_t */
00425 #define     SCNiPTR         SCNi16
00426 
00427 /** \ingroup avr_inttypes
00428     octal scanf format for uint8_t */
00429 #define     SCNo8           "hho"
00430 /** \ingroup avr_inttypes
00431     octal scanf format for uint_least8_t */
00432 #define     SCNoLEAST8      "hho"
00433 /** \ingroup avr_inttypes
00434     octal scanf format for uint_fast8_t */
00435 #define     SCNoFAST8       "hho"
00436 
00437 /** \ingroup avr_inttypes
00438     decimal scanf format for uint8_t */
00439 #define     SCNu8           "hhu"
00440 /** \ingroup avr_inttypes
00441     decimal scanf format for uint_least8_t */
00442 #define     SCNuLEAST8      "hhu"
00443 /** \ingroup avr_inttypes
00444     decimal scanf format for uint_fast8_t */
00445 #define     SCNuFAST8       "hhu"
00446 
00447 /** \ingroup avr_inttypes
00448     hexadecimal scanf format for uint8_t */
00449 #define     SCNx8           "hhx"
00450 /** \ingroup avr_inttypes
00451     hexadecimal scanf format for uint_least8_t */
00452 #define     SCNxLEAST8      "hhx"
00453 /** \ingroup avr_inttypes
00454     hexadecimal scanf format for uint_fast8_t */
00455 #define     SCNxFAST8       "hhx"
00456 
00457 /** \ingroup avr_inttypes
00458     octal scanf format for uint16_t */
00459 #define     SCNo16          "o"
00460 /** \ingroup avr_inttypes
00461     octal scanf format for uint_least16_t */
00462 #define     SCNoLEAST16     "o"
00463 /** \ingroup avr_inttypes
00464     octal scanf format for uint_fast16_t */
00465 #define     SCNoFAST16      "o"
00466 
00467 /** \ingroup avr_inttypes
00468     decimal scanf format for uint16_t */
00469 #define     SCNu16          "u"
00470 /** \ingroup avr_inttypes
00471     decimal scanf format for uint_least16_t */
00472 #define     SCNuLEAST16     "u"
00473 /** \ingroup avr_inttypes
00474     decimal scanf format for uint_fast16_t */
00475 #define     SCNuFAST16      "u"
00476 
00477 /** \ingroup avr_inttypes
00478     hexadecimal scanf format for uint16_t */
00479 #define     SCNx16          "x"
00480 /** \ingroup avr_inttypes
00481     hexadecimal scanf format for uint_least16_t */
00482 #define     SCNxLEAST16     "x"
00483 /** \ingroup avr_inttypes
00484     hexadecimal scanf format for uint_fast16_t */
00485 #define     SCNxFAST16      "x"
00486 
00487 
00488 /** \ingroup avr_inttypes
00489     octal scanf format for uint32_t */
00490 #define     SCNo32          "lo"
00491 /** \ingroup avr_inttypes
00492     octal scanf format for uint_least32_t */
00493 #define     SCNoLEAST32     "lo"
00494 /** \ingroup avr_inttypes
00495     octal scanf format for uint_fast32_t */
00496 #define     SCNoFAST32      "lo"
00497 
00498 /** \ingroup avr_inttypes
00499     decimal scanf format for uint32_t */
00500 #define     SCNu32          "lu"
00501 /** \ingroup avr_inttypes
00502     decimal scanf format for uint_least32_t */
00503 #define     SCNuLEAST32     "lu"
00504 /** \ingroup avr_inttypes
00505     decimal scanf format for uint_fast32_t */
00506 #define     SCNuFAST32      "lu"
00507 
00508 /** \ingroup avr_inttypes
00509     hexadecimal scanf format for uint32_t */
00510 #define     SCNx32          "lx"
00511 /** \ingroup avr_inttypes
00512     hexadecimal scanf format for uint_least32_t */
00513 #define     SCNxLEAST32     "lx"
00514 /** \ingroup avr_inttypes
00515     hexadecimal scanf format for uint_fast32_t */
00516 #define     SCNxFAST32      "lx"
00517 
00518 
00519 #ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf
00520 
00521 #define     SCNo64          "llo"
00522 #define     SCNoLEAST64     "llo"
00523 #define     SCNoFAST64      "llo"
00524 
00525 #define     SCNu64          "llu"
00526 #define     SCNuLEAST64     "llu"
00527 #define     SCNuFAST64      "llu"
00528 
00529 #define     SCNx64          "llx"
00530 #define     SCNxLEAST64     "llx"
00531 #define     SCNxFAST64      "llx"
00532 
00533 #define     SCNoMAX         "llo"
00534 #define     SCNuMAX         "llu"
00535 #define     SCNxMAX         "llx"
00536 
00537 #endif
00538 
00539 /** \ingroup avr_inttypes
00540     octal scanf format for uintptr_t */
00541 #define     SCNoPTR         SCNo16
00542 /** \ingroup avr_inttypes
00543     decimal scanf format for uintptr_t */
00544 #define     SCNuPTR         SCNu16
00545 /** \ingroup avr_inttypes
00546     hexadecimal scanf format for uintptr_t */
00547 #define     SCNxPTR         SCNx16
00548 
00549 /*@}*/
00550 
00551 
00552 #endif  /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
00553 
00554 
00555 #endif /* __INTTYPES_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Defines