avr_inttypes(3)
π avr_inttypes β avr-libc, section 3 π
okay bestie, sit down, hydrate, because this is the <inttypes.h> page and it is long. it's giving "reference material" and honestly? we're obsessed. this is part 1, so buckle up, more is coming. π¦
β¨ NAME β¨
avr_inttypes β the header that hands you portable integer types and the exact little format-specifier macros so your printf() and scanf() stop being a guessing game π
πΈ SYNOPSIS πΈ
πΊοΈ Far pointers for memory access >64K
typedef int32_t int_farptr_t
typedef uint32_t uint_farptr_t
π macros for printf and scanf format specifiers
For C++, these are only included if__STDC_LIMIT_MACROSis defined before including<inttypes.h>. not optional, not a suggestion, define it before, periodt.
#define PRId8 'd'
#define PRIdLEAST8 'd'
#define PRIdFAST8 'd'
#define PRIi8 'i'
#define PRIiLEAST8 'i'
#define PRIiFAST8 'i'
#define PRId16 'd'
#define PRIdLEAST16 'd'
#define PRIdFAST16 'd'
#define PRIi16 'i'
#define PRIiLEAST16 'i'
#define PRIiFAST16 'i'
#define PRId32 'ld'
#define PRIdLEAST32 'ld'
#define PRIdFAST32 'ld'
#define PRIi32 'li'
#define PRIiLEAST32 'li'
#define PRIiFAST32 'li'
#define PRIdPTR PRId16
#define PRIiPTR PRIi16
#define PRIo8 'o'
#define PRIoLEAST8 'o'
#define PRIoFAST8 'o'
#define PRIu8 'u'
#define PRIuLEAST8 'u'
#define PRIuFAST8 'u'
#define PRIx8 'x'
#define PRIxLEAST8 'x'
#define PRIxFAST8 'x'
#define PRIX8 'X'
#define PRIXLEAST8 'X'
#define PRIXFAST8 'X'
#define PRIo16 'o'
#define PRIoLEAST16 'o'
#define PRIoFAST16 'o'
#define PRIu16 'u'
#define PRIuLEAST16 'u'
#define PRIuFAST16 'u'
#define PRIx16 'x'
#define PRIxLEAST16 'x'
#define PRIxFAST16 'x'
#define PRIX16 'X'
#define PRIXLEAST16 'X'
#define PRIXFAST16 'X'
#define PRIo32 'lo'
#define PRIoLEAST32 'lo'
#define PRIoFAST32 'lo'
#define PRIu32 'lu'
#define PRIuLEAST32 'lu'
#define PRIuFAST32 'lu'
#define PRIx32 'lx'
#define PRIxLEAST32 'lx'
#define PRIxFAST32 'lx'
#define PRIX32 'lX'
#define PRIXLEAST32 'lX'
#define PRIXFAST32 'lX'
#define PRIoPTR PRIo16
#define PRIuPTR PRIu16
#define PRIxPTR PRIx16
#define PRIXPTR PRIX16
#define SCNd8 'hhd'
#define SCNdLEAST8 'hhd'
#define SCNdFAST8 'hhd'
#define SCNi8 'hhi'
#define SCNiLEAST8 'hhi'
#define SCNiFAST8 'hhi'
#define SCNd16 'd'
#define SCNdLEAST16 'd'
#define SCNdFAST16 'd'
#define SCNi16 'i'
#define SCNiLEAST16 'i'
#define SCNiFAST16 'i'
#define SCNd32 'ld'
#define SCNdLEAST32 'ld'
#define SCNdFAST32 'ld'
#define SCNi32 'li'
#define SCNiLEAST32 'li'
#define SCNiFAST32 'li'
#define SCNdPTR SCNd16
#define SCNiPTR SCNi16
#define SCNo8 'hho'
#define SCNoLEAST8 'hho'
#define SCNoFAST8 'hho'
#define SCNu8 'hhu'
#define SCNuLEAST8 'hhu'
#define SCNuFAST8 'hhu'
#define SCNx8 'hhx'
#define SCNxLEAST8 'hhx'
#define SCNxFAST8 'hhx'
#define SCNo16 'o'
#define SCNoLEAST16 'o'
#define SCNoFAST16 'o'
#define SCNu16 'u'
#define SCNuLEAST16 'u'
#define SCNuFAST16 'u'
#define SCNx16 'x'
#define SCNxLEAST16 'x'
#define SCNxFAST16 'x'
#define SCNo32 'lo'
#define SCNoLEAST32 'lo'
#define SCNoFAST32 'lo'
#define SCNu32 'lu'
#define SCNuLEAST32 'lu'
#define SCNuFAST32 'lu'
#define SCNx32 'lx'
#define SCNxLEAST32 'lx'
#define SCNxFAST32 'lx'
#define SCNoPTR SCNo16
#define SCNuPTR SCNu16
#define SCNxPTR SCNx16
like. that's the whole roster. every single one is here, no cap. π₯
π Detailed Description π
#include <inttypes.h>
so here's the tea, bestie. this header file includes the exact-width integer definitions from <stdint.h>, and then it extends them with extra facilities that the implementation provides. it's the stdint glow-up. β¨
right now, those extensions are:
- two extra integer types that can hold a 'far' pointer β and by far we mean a code pointer that can address more than 64 KB πΊοΈ
- standard names for all the
printfandscanfformatting options that are supported by the<stdio.h>: Standard IO facilities.
and lowkey important: since the library does not support the full range of conversion specifiers from ISO 9899:1999, only the conversions that are actually implemented get listed here. no fake options, only the real ones. π
the whole idea behind these conversion macros? for each of the types defined by <stdint.h>, you get a macro that portably lets you format an object of that type in printf() or scanf() operations. no more hardcoding %d and praying. π
Example:
#include <inttypes.h>
uint8_t smallval;
int32_t longval;
...
printf("The hexadecimal value of smallval is %" PRIx8
", the decimal value of longval is %" PRId32 ".0,
smallval, longval);
see how the macro sits right there in the middle of the string, chillin' between the quotes? that's the whole vibe. π«Ά
more of this page is coming in part 2, so don't go anywhere bestie π
the d girlies (decimal printf): π
#define PRId16 'd'β decimalprintfformat forint16_tπ#define PRId32 'ld'β decimalprintfformat forint32_t#define PRId8 'd'β decimalprintfformat forint8_t#define PRIdFAST16 'd'β decimalprintfformat forint_fast16_t#define PRIdFAST32 'ld'β decimalprintfformat forint_fast32_t#define PRIdFAST8 'd'β decimalprintfformat forint_fast8_t#define PRIdLEAST16 'd'β decimalprintfformat forint_least16_t#define PRIdLEAST32 'ld'β decimalprintfformat forint_least32_t#define PRIdLEAST8 'd'β decimalprintfformat forint_least8_t#define PRIdPTR PRId16β decimalprintfformat forintptr_t(it literally just isPRId16, no cap π«Ά)
the i besties (integer printf): πΈ
#define PRIi16 'i'β integerprintfformat forint16_t#define PRIi32 'li'β integerprintfformat forint32_t#define PRIi8 'i'β integerprintfformat forint8_t#define PRIiFAST16 'i'β integerprintfformat forint_fast16_t#define PRIiFAST32 'li'β integerprintfformat forint_fast32_t#define PRIiFAST8 'i'β integerprintfformat forint_fast8_t#define PRIiLEAST16 'i'β integerprintfformat forint_least16_t#define PRIiLEAST32 'li'β integerprintfformat forint_least32_t#define PRIiLEAST8 'i'β integerprintfformat forint_least8_t#define PRIiPTR PRIi16β integerprintfformat forintptr_t
the o cuties (octal printf): π
#define PRIo16 'o'β octalprintfformat foruint16_t#define PRIo32 'lo'β octalprintfformat foruint32_t#define PRIo8 'o'β octalprintfformat foruint8_t#define PRIoFAST16 'o'β octalprintfformat foruint_fast16_t#define PRIoFAST32 'lo'β octalprintfformat foruint_fast32_t#define PRIoFAST8 'o'β octalprintfformat foruint_fast8_t#define PRIoLEAST16 'o'β octalprintfformat foruint_least16_t#define PRIoLEAST32 'lo'β octalprintfformat foruint_least32_t#define PRIoLEAST8 'o'β octalprintfformat foruint_least8_t#define PRIoPTR PRIo16β octalprintfformat foruintptr_t
the u squad (decimal-but-unsigned printf): π
#define PRIu16 'u'β decimalprintfformat foruint16_t#define PRIu32 'lu'β decimalprintfformat foruint32_t#define PRIu8 'u'β decimalprintfformat foruint8_t#define PRIuFAST16 'u'β decimalprintfformat foruint_fast16_t#define PRIuFAST32 'lu'β decimalprintfformat foruint_fast32_t#define PRIuFAST8 'u'β decimalprintfformat foruint_fast8_t#define PRIuLEAST16 'u'β decimalprintfformat foruint_least16_t#define PRIuLEAST32 'lu'β decimalprintfformat foruint_least32_t#define PRIuLEAST8 'u'β decimalprintfformat foruint_least8_t#define PRIuPTR PRIu16β decimalprintfformat foruintptr_t
the hex girlies (lowercase x AND uppercase X, both slaying): π₯
#define PRIx16 'x'β hexadecimalprintfformat foruint16_t#define PRIX16 'X'β uppercase hexadecimalprintfformat foruint16_t#define PRIx32 'lx'β hexadecimalprintfformat foruint32_t#define PRIX32 'lX'β uppercase hexadecimalprintfformat foruint32_t#define PRIx8 'x'β hexadecimalprintfformat foruint8_t#define PRIX8 'X'β uppercase hexadecimalprintfformat foruint8_t#define PRIxFAST16 'x'β hexadecimalprintfformat foruint_fast16_t#define PRIXFAST16 'X'β uppercase hexadecimalprintfformat foruint_fast16_t#define PRIxFAST32 'lx'β hexadecimalprintfformat foruint_fast32_t#define PRIXFAST32 'lX'β uppercase hexadecimalprintfformat foruint_fast32_t#define PRIxFAST8 'x'β hexadecimalprintfformat foruint_fast8_t#define PRIXFAST8 'X'β uppercase hexadecimalprintfformat foruint_fast8_t#define PRIxLEAST16 'x'β hexadecimalprintfformat foruint_least16_t#define PRIXLEAST16 'X'β uppercase hexadecimalprintfformat foruint_least16_t#define PRIxLEAST32 'lx'β hexadecimalprintfformat foruint_least32_t#define PRIXLEAST32 'lX'β uppercase hexadecimalprintfformat foruint_least32_t#define PRIxLEAST8 'x'β hexadecimalprintfformat foruint_least8_t#define PRIXLEAST8 'X'β uppercase hexadecimalprintfformat foruint_least8_t#define PRIxPTR PRIx16β hexadecimalprintfformat foruintptr_t#define PRIXPTR PRIX16β uppercase hexadecimalprintfformat foruintptr_t
okay and NOW we flip it, bestie β this is the scanf side of the family π same energy, but for reading values instead of printing them. Notice how the 8-bit ones get that little hh prefix (iconic, honestly) π
the d crew (decimal scanf): π¦
#define SCNd16 'd'β decimalscanfformat forint16_t#define SCNd32 'ld'β decimalscanfformat forint32_t#define SCNd8 'hhd'β decimalscanfformat forint8_t#define SCNdFAST16 'd'β decimalscanfformat forint_fast16_t#define SCNdFAST32 'ld'β decimalscanfformat forint_fast32_t#define SCNdFAST8 'hhd'β decimalscanfformat forint_fast8_t#define SCNdLEAST16 'd'β decimalscanfformat forint_least16_t#define SCNdLEAST32 'ld'β decimalscanfformat forint_least32_t#define SCNdLEAST8 'hhd'β decimalscanfformat forint_least8_t#define SCNdPTR SCNd16β decimalscanfformat forintptr_t
the i crew (generic-integer scanf): β
#define SCNi16 'i'β generic-integerscanfformat forint16_t#define SCNi32 'li'β generic-integerscanfformat forint32_t#define SCNi8 'hhi'β generic-integerscanfformat forint8_t#define SCNiFAST16 'i'β generic-integerscanfformat forint_fast16_t#define SCNiFAST32 'li'β generic-integerscanfformat forint_fast32_t#define SCNiFAST8 'hhi'β generic-integerscanfformat forint_fast8_t#define SCNiLEAST16 'i'β generic-integerscanfformat forint_least16_t#define SCNiLEAST32 'li'β generic-integerscanfformat forint_least32_t#define SCNiLEAST8 'hhi'β generic-integerscanfformat forint_least8_t#define SCNiPTR SCNi16β generic-integerscanfformat forintptr_t
the o crew (octal scanf): π§
#define SCNo16 'o'β octalscanfformat foruint16_t#define SCNo32 'lo'β octalscanfformat foruint32_t#define SCNo8 'hho'β octalscanfformat foruint8_t#define SCNoFAST16 'o'β octalscanfformat foruint_fast16_t#define SCNoFAST32 'lo'β octalscanfformat foruint_fast32_t#define SCNoFAST8 'hho'β octalscanfformat foruint_fast8_t#define SCNoLEAST16 'o'β octalscanfformat foruint_least16_t#define SCNoLEAST32 'lo'β octalscanfformat foruint_least32_t#define SCNoLEAST8 'hho'β octalscanfformat foruint_least8_t#define SCNoPTR SCNo16β octalscanfformat foruintptr_t
the u crew (decimal scanf): πΈ
#define SCNu16 'u'β decimalscanfformat foruint16_t#define SCNu32 'lu'β decimalscanfformat foruint32_t#define SCNu8 'hhu'β decimalscanfformat foruint8_t#define SCNuFAST16 'u'β decimalscanfformat foruint_fast16_t#define SCNuFAST32 'lu'β decimalscanfformat foruint_fast32_t#define SCNuFAST8 'hhu'β decimalscanfformat foruint_fast8_t#define SCNuLEAST16 'u'β decimalscanfformat foruint_least16_t#define SCNuLEAST32 'lu'β decimalscanfformat foruint_least32_t#define SCNuLEAST8 'hhu'β decimalscanfformat foruint_least8_t#define SCNuPTR SCNu16β decimalscanfformat foruintptr_t
the x crew (hexadecimal scanf): β¨
#define SCNx16 'x'β hexadecimalscanfformat foruint16_t#define SCNx32 'lx'β hexadecimalscanfformat foruint32_t#define SCNx8 'hhx'β hexadecimalscanfformat foruint8_t#define SCNxFAST16 'x'β hexadecimalscanfformat foruint_fast16_t#define SCNxFAST32 'lx'β hexadecimalscanfformat foruint_fast32_t#define SCNxFAST8 'hhx'β hexadecimalscanfformat foruint_fast8_t#define SCNxLEAST16 'x'β hexadecimalscanfformat foruint_least16_t#define SCNxLEAST32 'lx'β hexadecimalscanfformat foruint_least32_t#define SCNxLEAST8 'hhx'β hexadecimalscanfformat foruint_least8_t#define SCNxPTR SCNx16β hexadecimalscanfformat foruintptr_t
π«Ά Typedef Documentation π«Ά
just two little typedefs hanging out at the end, no biggie, but they MATTER if you're on one of those chips with big ol' memory spaces π
typedef int32_t int_farptr_tβ signed integer type that can hold a pointer > 64 KB πtypedef uint32_t uint_farptr_tβ unsigned integer type that can hold a pointer > 64 KB π
π Author π
Generated automatically by Doxygen for avr-libc from the source code.
and that's a wrap, bestie π this whole glow-up was auto-generated by Doxygen for avr-libc, version 2.1.0, dated Sat Jan 29 2022 β go forth and format your ints correctly, ily π β¨
π¦ where this page comes from
- fedora 43: avr-libc 2.2.1-3.fc43 Β· BSD-3-Clause
- fedora 44: avr-libc 2.2.1-5.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: avr-libc 2.1.0-bp160.1.33 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms