AVR Libc Home Page AVRs AVR Libc Development Pages
Main Page User Manual Reference FAQ Example Projects

inttypes.h

Go to the documentation of this file.
01	1 Copyright (c) 2004,2005,2007,2012 Joerg Wunsch
022Copyright (c) 2005, Carlos Lamas 033All rights reserved. 044 055Redistribution and use in source and binary forms, with or without 066modification, are permitted provided that the following conditions are met: 077 088* Redistributions of source code must retain the above copyright 099notice, this list of conditions and the following disclaimer. 1010 1111* Redistributions in binary form must reproduce the above copyright 1212notice, this list of conditions and the following disclaimer in 1313the documentation and/or other materials provided with the 1414distribution. 1515 1616* Neither the name of the copyright holders nor the names of 1717contributors may be used to endorse or promote products derived 1818from this software without specific prior written permission. 1919 2020THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2121AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2222IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2323ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2424LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2525CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2626SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2727INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2828CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2929ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3030POSSIBILITY OF SUCH DAMAGE. */ 3131 3232/* $Id: inttypes.h 2302 2012-11-26 10:52:01Z joerg_wunsch $ */ 3333 3434#ifndef __INTTYPES_H_ 3535#define __INTTYPES_H_ 3636 3737#include <stdint.h> 3838 3939/** \file */ 4040/** \defgroup avr_inttypes <inttypes.h>: Integer Type conversions 4141\code #include <inttypes.h> \endcode 4242 4343This header file includes the exact-width integer definitions from 4444<tt><stdint.h></tt>, and extends them with additional facilities 4545provided by the implementation. 4646 4747Currently, the extensions include two additional integer types 4848that could hold a "far" pointer (i.e. a code pointer that can 4949address more than 64 KB), as well as standard names for all printf 5050and scanf formatting options that are supported by the \ref avr_stdio. 5151As the library does not support the full range of conversion 5252specifiers from ISO 9899:1999, only those conversions that are 5353actually implemented will be listed here. 5454 5555The idea behind these conversion macros is that, for each of the 5656types defined by <stdint.h>, a macro will be supplied that portably 5757allows formatting an object of that type in printf() or scanf() 5858operations. Example: 5959 6060\code 6161#include <inttypes.h> 6262 6363uint8_t smallval; 6464int32_t longval; 6565... 6666printf("The hexadecimal value of smallval is %" PRIx8 6767", the decimal value of longval is %" PRId32 ".\n", 6868smallval, longval); 6969\endcode 7070*/ 7171 7272/** \name Far pointers for memory access >64K */ 7373 7474/*@{*/ 7575/** \ingroup avr_inttypes 7676signed integer type that can hold a pointer >> 64 KB */ 77 77 typedef int32_t int_farptr_t; 7878 7979/** \ingroup avr_inttypes 8080unsigned integer type that can hold a pointer >> 64 KB */ 81 81 typedef uint32_t uint_farptr_t; 8282/*@}*/ 8383 8484#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) 8585 8686 8787/** \name macros for printf and scanf format specifiers 8888 8989For C++, these are only included if __STDC_LIMIT_MACROS 9090is defined before including <inttypes.h>. 9191*/ 9292 9393/*@{*/ 9494/** \ingroup avr_inttypes 9595decimal printf format for int8_t */ 96 96#define PRId8 "d" 9797/** \ingroup avr_inttypes 9898decimal printf format for int_least8_t */ 99 99#define PRIdLEAST8 "d" 100100/** \ingroup avr_inttypes 101101decimal printf format for int_fast8_t */ 102 102#define PRIdFAST8 "d" 103103 104104/** \ingroup avr_inttypes 105105integer printf format for int8_t */ 106 106#define PRIi8 "i" 107107/** \ingroup avr_inttypes 108108integer printf format for int_least8_t */ 109 109#define PRIiLEAST8 "i" 110110/** \ingroup avr_inttypes 111111integer printf format for int_fast8_t */ 112 112#define PRIiFAST8 "i" 113113 114114 115115/** \ingroup avr_inttypes 116116decimal printf format for int16_t */ 117 117#define PRId16 "d" 118118/** \ingroup avr_inttypes 119119decimal printf format for int_least16_t */ 120 120#define PRIdLEAST16 "d" 121121/** \ingroup avr_inttypes 122122decimal printf format for int_fast16_t */ 123 123#define PRIdFAST16 "d" 124124 125125/** \ingroup avr_inttypes 126126integer printf format for int16_t */ 127 127#define PRIi16 "i" 128128/** \ingroup avr_inttypes 129129integer printf format for int_least16_t */ 130 130#define PRIiLEAST16 "i" 131131/** \ingroup avr_inttypes 132132integer printf format for int_fast16_t */ 133 133#define PRIiFAST16 "i" 134134 135135 136136/** \ingroup avr_inttypes 137137decimal printf format for int32_t */ 138 138#define PRId32 "ld" 139139/** \ingroup avr_inttypes 140140decimal printf format for int_least32_t */ 141 141#define PRIdLEAST32 "ld" 142142/** \ingroup avr_inttypes 143143decimal printf format for int_fast32_t */ 144 144#define PRIdFAST32 "ld" 145145 146146/** \ingroup avr_inttypes 147147integer printf format for int32_t */ 148 148#define PRIi32 "li" 149149/** \ingroup avr_inttypes 150150integer printf format for int_least32_t */ 151 151#define PRIiLEAST32 "li" 152152/** \ingroup avr_inttypes 153153integer printf format for int_fast32_t */ 154 154#define PRIiFAST32 "li" 155155 156156 157157#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf 158158 159159#define PRId64 "lld" 160160#define PRIdLEAST64 "lld" 161161#define PRIdFAST64 "lld" 162162 163163#define PRIi64 "lli" 164164#define PRIiLEAST64 "lli" 165165#define PRIiFAST64 "lli" 166166 167167 168168#define PRIdMAX "lld" 169169#define PRIiMAX "lli" 170170 171171#endif 172172 173173/** \ingroup avr_inttypes 174174decimal printf format for intptr_t */ 175 175#define PRIdPTR PRId16 176176/** \ingroup avr_inttypes 177177integer printf format for intptr_t */ 178 178#define PRIiPTR PRIi16 179179 180180/** \ingroup avr_inttypes 181181octal printf format for uint8_t */ 182 182#define PRIo8 "o" 183183/** \ingroup avr_inttypes 184184octal printf format for uint_least8_t */ 185 185#define PRIoLEAST8 "o" 186186/** \ingroup avr_inttypes 187187octal printf format for uint_fast8_t */ 188 188#define PRIoFAST8 "o" 189189 190190/** \ingroup avr_inttypes 191191decimal printf format for uint8_t */ 192 192#define PRIu8 "u" 193193/** \ingroup avr_inttypes 194194decimal printf format for uint_least8_t */ 195 195#define PRIuLEAST8 "u" 196196/** \ingroup avr_inttypes 197197decimal printf format for uint_fast8_t */ 198 198#define PRIuFAST8 "u" 199199 200200/** \ingroup avr_inttypes 201201hexadecimal printf format for uint8_t */ 202 202#define PRIx8 "x" 203203/** \ingroup avr_inttypes 204204hexadecimal printf format for uint_least8_t */ 205 205#define PRIxLEAST8 "x" 206206/** \ingroup avr_inttypes 207207hexadecimal printf format for uint_fast8_t */ 208 208#define PRIxFAST8 "x" 209209 210210/** \ingroup avr_inttypes 211211uppercase hexadecimal printf format for uint8_t */ 212 212#define PRIX8 "X" 213213/** \ingroup avr_inttypes 214214uppercase hexadecimal printf format for uint_least8_t */ 215 215#define PRIXLEAST8 "X" 216216/** \ingroup avr_inttypes 217217uppercase hexadecimal printf format for uint_fast8_t */ 218 218#define PRIXFAST8 "X" 219219 220220 221221/** \ingroup avr_inttypes 222222octal printf format for uint16_t */ 223 223#define PRIo16 "o" 224224/** \ingroup avr_inttypes 225225octal printf format for uint_least16_t */ 226 226#define PRIoLEAST16 "o" 227227/** \ingroup avr_inttypes 228228octal printf format for uint_fast16_t */ 229 229#define PRIoFAST16 "o" 230230 231231/** \ingroup avr_inttypes 232232decimal printf format for uint16_t */ 233 233#define PRIu16 "u" 234234/** \ingroup avr_inttypes 235235decimal printf format for uint_least16_t */ 236 236#define PRIuLEAST16 "u" 237237/** \ingroup avr_inttypes 238238decimal printf format for uint_fast16_t */ 239 239#define PRIuFAST16 "u" 240240 241241/** \ingroup avr_inttypes 242242hexadecimal printf format for uint16_t */ 243 243#define PRIx16 "x" 244244/** \ingroup avr_inttypes 245245hexadecimal printf format for uint_least16_t */ 246 246#define PRIxLEAST16 "x" 247247/** \ingroup avr_inttypes 248248hexadecimal printf format for uint_fast16_t */ 249 249#define PRIxFAST16 "x" 250250 251251/** \ingroup avr_inttypes 252252uppercase hexadecimal printf format for uint16_t */ 253 253#define PRIX16 "X" 254254/** \ingroup avr_inttypes 255255uppercase hexadecimal printf format for uint_least16_t */ 256 256#define PRIXLEAST16 "X" 257257/** \ingroup avr_inttypes 258258uppercase hexadecimal printf format for uint_fast16_t */ 259 259#define PRIXFAST16 "X" 260260 261261 262262/** \ingroup avr_inttypes 263263octal printf format for uint32_t */ 264 264#define PRIo32 "lo" 265265/** \ingroup avr_inttypes 266266octal printf format for uint_least32_t */ 267 267#define PRIoLEAST32 "lo" 268268/** \ingroup avr_inttypes 269269octal printf format for uint_fast32_t */ 270 270#define PRIoFAST32 "lo" 271271 272272/** \ingroup avr_inttypes 273273decimal printf format for uint32_t */ 274 274#define PRIu32 "lu" 275275/** \ingroup avr_inttypes 276276decimal printf format for uint_least32_t */ 277 277#define PRIuLEAST32 "lu" 278278/** \ingroup avr_inttypes 279279decimal printf format for uint_fast32_t */ 280 280#define PRIuFAST32 "lu" 281281 282282/** \ingroup avr_inttypes 283283hexadecimal printf format for uint32_t */ 284 284#define PRIx32 "lx" 285285/** \ingroup avr_inttypes 286286hexadecimal printf format for uint_least32_t */ 287 287#define PRIxLEAST32 "lx" 288288/** \ingroup avr_inttypes 289289hexadecimal printf format for uint_fast32_t */ 290 290#define PRIxFAST32 "lx" 291291 292292/** \ingroup avr_inttypes 293293uppercase hexadecimal printf format for uint32_t */ 294 294#define PRIX32 "lX" 295295/** \ingroup avr_inttypes 296296uppercase hexadecimal printf format for uint_least32_t */ 297 297#define PRIXLEAST32 "lX" 298298/** \ingroup avr_inttypes 299299uppercase hexadecimal printf format for uint_fast32_t */ 300 300#define PRIXFAST32 "lX" 301301 302302 303303#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf 304304 305305#define PRIo64 "llo" 306306#define PRIoLEAST64 "llo" 307307#define PRIoFAST64 "llo" 308308 309309#define PRIu64 "llu" 310310#define PRIuLEAST64 "llu" 311311#define PRIuFAST64 "llu" 312312 313313#define PRIx64 "llx" 314314#define PRIxLEAST64 "llx" 315315#define PRIxFAST64 "llx" 316316 317317#define PRIX64 "llX" 318318#define PRIXLEAST64 "llX" 319319#define PRIXFAST64 "llX" 320320 321321#define PRIoMAX "llo" 322322#define PRIuMAX "llu" 323323#define PRIxMAX "llx" 324324#define PRIXMAX "llX" 325325 326326#endif 327327 328328/** \ingroup avr_inttypes 329329octal printf format for uintptr_t */ 330 330#define PRIoPTR PRIo16 331331/** \ingroup avr_inttypes 332332decimal printf format for uintptr_t */ 333 333#define PRIuPTR PRIu16 334334/** \ingroup avr_inttypes 335335hexadecimal printf format for uintptr_t */ 336 336#define PRIxPTR PRIx16 337337/** \ingroup avr_inttypes 338338uppercase hexadecimal printf format for uintptr_t */ 339 339#define PRIXPTR PRIX16 340340 341341 342342/** \ingroup avr_inttypes 343343decimal scanf format for int8_t */ 344 344#define SCNd8 "hhd" 345345/** \ingroup avr_inttypes 346346decimal scanf format for int_least8_t */ 347 347#define SCNdLEAST8 "hhd" 348348/** \ingroup avr_inttypes 349349decimal scanf format for int_fast8_t */ 350 350#define SCNdFAST8 "hhd" 351351 352352/** \ingroup avr_inttypes 353353generic-integer scanf format for int8_t */ 354 354#define SCNi8 "hhi" 355355/** \ingroup avr_inttypes 356356generic-integer scanf format for int_least8_t */ 357 357#define SCNiLEAST8 "hhi" 358358/** \ingroup avr_inttypes 359359generic-integer scanf format for int_fast8_t */ 360 360#define SCNiFAST8 "hhi" 361361 362362 363363/** \ingroup avr_inttypes 364364decimal scanf format for int16_t */ 365 365#define SCNd16 "d" 366366/** \ingroup avr_inttypes 367367decimal scanf format for int_least16_t */ 368 368#define SCNdLEAST16 "d" 369369/** \ingroup avr_inttypes 370370decimal scanf format for int_fast16_t */ 371 371#define SCNdFAST16 "d" 372372 373373/** \ingroup avr_inttypes 374374generic-integer scanf format for int16_t */ 375 375#define SCNi16 "i" 376376/** \ingroup avr_inttypes 377377generic-integer scanf format for int_least16_t */ 378 378#define SCNiLEAST16 "i" 379379/** \ingroup avr_inttypes 380380generic-integer scanf format for int_fast16_t */ 381 381#define SCNiFAST16 "i" 382382 383383 384384/** \ingroup avr_inttypes 385385decimal scanf format for int32_t */ 386 386#define SCNd32 "ld" 387387/** \ingroup avr_inttypes 388388decimal scanf format for int_least32_t */ 389 389#define SCNdLEAST32 "ld" 390390/** \ingroup avr_inttypes 391391decimal scanf format for int_fast32_t */ 392 392#define SCNdFAST32 "ld" 393393 394394/** \ingroup avr_inttypes 395395generic-integer scanf format for int32_t */ 396 396#define SCNi32 "li" 397397/** \ingroup avr_inttypes 398398generic-integer scanf format for int_least32_t */ 399 399#define SCNiLEAST32 "li" 400400/** \ingroup avr_inttypes 401401generic-integer scanf format for int_fast32_t */ 402 402#define SCNiFAST32 "li" 403403 404404 405405#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf 406406 407407#define SCNd64 "lld" 408408#define SCNdLEAST64 "lld" 409409#define SCNdFAST64 "lld" 410410 411411#define SCNi64 "lli" 412412#define SCNiLEAST64 "lli" 413413#define SCNiFAST64 "lli" 414414 415415#define SCNdMAX "lld" 416416#define SCNiMAX "lli" 417417 418418#endif 419419 420420/** \ingroup avr_inttypes 421421decimal scanf format for intptr_t */ 422 422#define SCNdPTR SCNd16 423423/** \ingroup avr_inttypes 424424generic-integer scanf format for intptr_t */ 425 425#define SCNiPTR SCNi16 426426 427427/** \ingroup avr_inttypes 428428octal scanf format for uint8_t */ 429 429#define SCNo8 "hho" 430430/** \ingroup avr_inttypes 431431octal scanf format for uint_least8_t */ 432 432#define SCNoLEAST8 "hho" 433433/** \ingroup avr_inttypes 434434octal scanf format for uint_fast8_t */ 435 435#define SCNoFAST8 "hho" 436436 437437/** \ingroup avr_inttypes 438438decimal scanf format for uint8_t */ 439 439#define SCNu8 "hhu" 440440/** \ingroup avr_inttypes 441441decimal scanf format for uint_least8_t */ 442 442#define SCNuLEAST8 "hhu" 443443/** \ingroup avr_inttypes 444444decimal scanf format for uint_fast8_t */ 445 445#define SCNuFAST8 "hhu" 446446 447447/** \ingroup avr_inttypes 448448hexadecimal scanf format for uint8_t */ 449 449#define SCNx8 "hhx" 450450/** \ingroup avr_inttypes 451451hexadecimal scanf format for uint_least8_t */ 452 452#define SCNxLEAST8 "hhx" 453453/** \ingroup avr_inttypes 454454hexadecimal scanf format for uint_fast8_t */ 455 455#define SCNxFAST8 "hhx" 456456 457457/** \ingroup avr_inttypes 458458octal scanf format for uint16_t */ 459 459#define SCNo16 "o" 460460/** \ingroup avr_inttypes 461461octal scanf format for uint_least16_t */ 462 462#define SCNoLEAST16 "o" 463463/** \ingroup avr_inttypes 464464octal scanf format for uint_fast16_t */ 465 465#define SCNoFAST16 "o" 466466 467467/** \ingroup avr_inttypes 468468decimal scanf format for uint16_t */ 469 469#define SCNu16 "u" 470470/** \ingroup avr_inttypes 471471decimal scanf format for uint_least16_t */ 472 472#define SCNuLEAST16 "u" 473473/** \ingroup avr_inttypes 474474decimal scanf format for uint_fast16_t */ 475 475#define SCNuFAST16 "u" 476476 477477/** \ingroup avr_inttypes 478478hexadecimal scanf format for uint16_t */ 479 479#define SCNx16 "x" 480480/** \ingroup avr_inttypes 481481hexadecimal scanf format for uint_least16_t */ 482 482#define SCNxLEAST16 "x" 483483/** \ingroup avr_inttypes 484484hexadecimal scanf format for uint_fast16_t */ 485 485#define SCNxFAST16 "x" 486486 487487 488488/** \ingroup avr_inttypes 489489octal scanf format for uint32_t */ 490 490#define SCNo32 "lo" 491491/** \ingroup avr_inttypes 492492octal scanf format for uint_least32_t */ 493 493#define SCNoLEAST32 "lo" 494494/** \ingroup avr_inttypes 495495octal scanf format for uint_fast32_t */ 496 496#define SCNoFAST32 "lo" 497497 498498/** \ingroup avr_inttypes 499499decimal scanf format for uint32_t */ 500 500#define SCNu32 "lu" 501501/** \ingroup avr_inttypes 502502decimal scanf format for uint_least32_t */ 503 503#define SCNuLEAST32 "lu" 504504/** \ingroup avr_inttypes 505505decimal scanf format for uint_fast32_t */ 506 506#define SCNuFAST32 "lu" 507507 508508/** \ingroup avr_inttypes 509509hexadecimal scanf format for uint32_t */ 510 510#define SCNx32 "lx" 511511/** \ingroup avr_inttypes 512512hexadecimal scanf format for uint_least32_t */ 513 513#define SCNxLEAST32 "lx" 514514/** \ingroup avr_inttypes 515515hexadecimal scanf format for uint_fast32_t */ 516 516#define SCNxFAST32 "lx" 517517 518518 519519#ifdef __avr_libc_does_not_implement_long_long_in_printf_or_scanf 520520 521521#define SCNo64 "llo" 522522#define SCNoLEAST64 "llo" 523523#define SCNoFAST64 "llo" 524524 525525#define SCNu64 "llu" 526526#define SCNuLEAST64 "llu" 527527#define SCNuFAST64 "llu" 528528 529529#define SCNx64 "llx" 530530#define SCNxLEAST64 "llx" 531531#define SCNxFAST64 "llx" 532532 533533#define SCNoMAX "llo" 534534#define SCNuMAX "llu" 535535#define SCNxMAX "llx" 536536 537537#endif 538538 539539/** \ingroup avr_inttypes 540540octal scanf format for uintptr_t */ 541 541#define SCNoPTR SCNo16 542542/** \ingroup avr_inttypes 543543decimal scanf format for uintptr_t */ 544 544#define SCNuPTR SCNu16 545545/** \ingroup avr_inttypes 546546hexadecimal scanf format for uintptr_t */ 547 547#define SCNxPTR SCNx16 548548 549549/*@}*/ 550550 551551 552552#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ 553553 554554 555555#endif /* __INTTYPES_H_ */

int_farptr_t int32_t int_farptr_t

Definition: inttypes.h:77

int32_t signed long int int32_t

Definition: stdint.h:98

uint_farptr_t uint32_t uint_farptr_t

Definition: inttypes.h:81

uint32_t unsigned long int uint32_t

Definition: stdint.h:103

stdint.h