avr_inttypes(3)

πŸ“¦ version 2.2.1, in fedora 43, fedora 44, opensuse-leap 16.0

πŸ‘‘ 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_MACROS is 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 printf and scanf formatting 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' β€” decimal printf format for int16_t πŸ’…
  • #define PRId32 'ld' β€” decimal printf format for int32_t
  • #define PRId8 'd' β€” decimal printf format for int8_t
  • #define PRIdFAST16 'd' β€” decimal printf format for int_fast16_t
  • #define PRIdFAST32 'ld' β€” decimal printf format for int_fast32_t
  • #define PRIdFAST8 'd' β€” decimal printf format for int_fast8_t
  • #define PRIdLEAST16 'd' β€” decimal printf format for int_least16_t
  • #define PRIdLEAST32 'ld' β€” decimal printf format for int_least32_t
  • #define PRIdLEAST8 'd' β€” decimal printf format for int_least8_t
  • #define PRIdPTR PRId16 β€” decimal printf format for intptr_t (it literally just is PRId16, no cap 🫢)

the i besties (integer printf): 🌸

  • #define PRIi16 'i' β€” integer printf format for int16_t
  • #define PRIi32 'li' β€” integer printf format for int32_t
  • #define PRIi8 'i' β€” integer printf format for int8_t
  • #define PRIiFAST16 'i' β€” integer printf format for int_fast16_t
  • #define PRIiFAST32 'li' β€” integer printf format for int_fast32_t
  • #define PRIiFAST8 'i' β€” integer printf format for int_fast8_t
  • #define PRIiLEAST16 'i' β€” integer printf format for int_least16_t
  • #define PRIiLEAST32 'li' β€” integer printf format for int_least32_t
  • #define PRIiLEAST8 'i' β€” integer printf format for int_least8_t
  • #define PRIiPTR PRIi16 β€” integer printf format for intptr_t

the o cuties (octal printf): πŸŽ€

  • #define PRIo16 'o' β€” octal printf format for uint16_t
  • #define PRIo32 'lo' β€” octal printf format for uint32_t
  • #define PRIo8 'o' β€” octal printf format for uint8_t
  • #define PRIoFAST16 'o' β€” octal printf format for uint_fast16_t
  • #define PRIoFAST32 'lo' β€” octal printf format for uint_fast32_t
  • #define PRIoFAST8 'o' β€” octal printf format for uint_fast8_t
  • #define PRIoLEAST16 'o' β€” octal printf format for uint_least16_t
  • #define PRIoLEAST32 'lo' β€” octal printf format for uint_least32_t
  • #define PRIoLEAST8 'o' β€” octal printf format for uint_least8_t
  • #define PRIoPTR PRIo16 β€” octal printf format for uintptr_t

the u squad (decimal-but-unsigned printf): πŸ’œ

  • #define PRIu16 'u' β€” decimal printf format for uint16_t
  • #define PRIu32 'lu' β€” decimal printf format for uint32_t
  • #define PRIu8 'u' β€” decimal printf format for uint8_t
  • #define PRIuFAST16 'u' β€” decimal printf format for uint_fast16_t
  • #define PRIuFAST32 'lu' β€” decimal printf format for uint_fast32_t
  • #define PRIuFAST8 'u' β€” decimal printf format for uint_fast8_t
  • #define PRIuLEAST16 'u' β€” decimal printf format for uint_least16_t
  • #define PRIuLEAST32 'lu' β€” decimal printf format for uint_least32_t
  • #define PRIuLEAST8 'u' β€” decimal printf format for uint_least8_t
  • #define PRIuPTR PRIu16 β€” decimal printf format for uintptr_t

the hex girlies (lowercase x AND uppercase X, both slaying): πŸ”₯

  • #define PRIx16 'x' β€” hexadecimal printf format for uint16_t
  • #define PRIX16 'X' β€” uppercase hexadecimal printf format for uint16_t
  • #define PRIx32 'lx' β€” hexadecimal printf format for uint32_t
  • #define PRIX32 'lX' β€” uppercase hexadecimal printf format for uint32_t
  • #define PRIx8 'x' β€” hexadecimal printf format for uint8_t
  • #define PRIX8 'X' β€” uppercase hexadecimal printf format for uint8_t
  • #define PRIxFAST16 'x' β€” hexadecimal printf format for uint_fast16_t
  • #define PRIXFAST16 'X' β€” uppercase hexadecimal printf format for uint_fast16_t
  • #define PRIxFAST32 'lx' β€” hexadecimal printf format for uint_fast32_t
  • #define PRIXFAST32 'lX' β€” uppercase hexadecimal printf format for uint_fast32_t
  • #define PRIxFAST8 'x' β€” hexadecimal printf format for uint_fast8_t
  • #define PRIXFAST8 'X' β€” uppercase hexadecimal printf format for uint_fast8_t
  • #define PRIxLEAST16 'x' β€” hexadecimal printf format for uint_least16_t
  • #define PRIXLEAST16 'X' β€” uppercase hexadecimal printf format for uint_least16_t
  • #define PRIxLEAST32 'lx' β€” hexadecimal printf format for uint_least32_t
  • #define PRIXLEAST32 'lX' β€” uppercase hexadecimal printf format for uint_least32_t
  • #define PRIxLEAST8 'x' β€” hexadecimal printf format for uint_least8_t
  • #define PRIXLEAST8 'X' β€” uppercase hexadecimal printf format for uint_least8_t
  • #define PRIxPTR PRIx16 β€” hexadecimal printf format for uintptr_t
  • #define PRIXPTR PRIX16 β€” uppercase hexadecimal printf format for uintptr_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' β€” decimal scanf format for int16_t
  • #define SCNd32 'ld' β€” decimal scanf format for int32_t
  • #define SCNd8 'hhd' β€” decimal scanf format for int8_t
  • #define SCNdFAST16 'd' β€” decimal scanf format for int_fast16_t
  • #define SCNdFAST32 'ld' β€” decimal scanf format for int_fast32_t
  • #define SCNdFAST8 'hhd' β€” decimal scanf format for int_fast8_t
  • #define SCNdLEAST16 'd' β€” decimal scanf format for int_least16_t
  • #define SCNdLEAST32 'ld' β€” decimal scanf format for int_least32_t
  • #define SCNdLEAST8 'hhd' β€” decimal scanf format for int_least8_t
  • #define SCNdPTR SCNd16 β€” decimal scanf format for intptr_t

the i crew (generic-integer scanf): ⭐

  • #define SCNi16 'i' β€” generic-integer scanf format for int16_t
  • #define SCNi32 'li' β€” generic-integer scanf format for int32_t
  • #define SCNi8 'hhi' β€” generic-integer scanf format for int8_t
  • #define SCNiFAST16 'i' β€” generic-integer scanf format for int_fast16_t
  • #define SCNiFAST32 'li' β€” generic-integer scanf format for int_fast32_t
  • #define SCNiFAST8 'hhi' β€” generic-integer scanf format for int_fast8_t
  • #define SCNiLEAST16 'i' β€” generic-integer scanf format for int_least16_t
  • #define SCNiLEAST32 'li' β€” generic-integer scanf format for int_least32_t
  • #define SCNiLEAST8 'hhi' β€” generic-integer scanf format for int_least8_t
  • #define SCNiPTR SCNi16 β€” generic-integer scanf format for intptr_t

the o crew (octal scanf): 🧚

  • #define SCNo16 'o' β€” octal scanf format for uint16_t
  • #define SCNo32 'lo' β€” octal scanf format for uint32_t
  • #define SCNo8 'hho' β€” octal scanf format for uint8_t
  • #define SCNoFAST16 'o' β€” octal scanf format for uint_fast16_t
  • #define SCNoFAST32 'lo' β€” octal scanf format for uint_fast32_t
  • #define SCNoFAST8 'hho' β€” octal scanf format for uint_fast8_t
  • #define SCNoLEAST16 'o' β€” octal scanf format for uint_least16_t
  • #define SCNoLEAST32 'lo' β€” octal scanf format for uint_least32_t
  • #define SCNoLEAST8 'hho' β€” octal scanf format for uint_least8_t
  • #define SCNoPTR SCNo16 β€” octal scanf format for uintptr_t

the u crew (decimal scanf): 🌸

  • #define SCNu16 'u' β€” decimal scanf format for uint16_t
  • #define SCNu32 'lu' β€” decimal scanf format for uint32_t
  • #define SCNu8 'hhu' β€” decimal scanf format for uint8_t
  • #define SCNuFAST16 'u' β€” decimal scanf format for uint_fast16_t
  • #define SCNuFAST32 'lu' β€” decimal scanf format for uint_fast32_t
  • #define SCNuFAST8 'hhu' β€” decimal scanf format for uint_fast8_t
  • #define SCNuLEAST16 'u' β€” decimal scanf format for uint_least16_t
  • #define SCNuLEAST32 'lu' β€” decimal scanf format for uint_least32_t
  • #define SCNuLEAST8 'hhu' β€” decimal scanf format for uint_least8_t
  • #define SCNuPTR SCNu16 β€” decimal scanf format for uintptr_t

the x crew (hexadecimal scanf): ✨

  • #define SCNx16 'x' β€” hexadecimal scanf format for uint16_t
  • #define SCNx32 'lx' β€” hexadecimal scanf format for uint32_t
  • #define SCNx8 'hhx' β€” hexadecimal scanf format for uint8_t
  • #define SCNxFAST16 'x' β€” hexadecimal scanf format for uint_fast16_t
  • #define SCNxFAST32 'lx' β€” hexadecimal scanf format for uint_fast32_t
  • #define SCNxFAST8 'hhx' β€” hexadecimal scanf format for uint_fast8_t
  • #define SCNxLEAST16 'x' β€” hexadecimal scanf format for uint_least16_t
  • #define SCNxLEAST32 'lx' β€” hexadecimal scanf format for uint_least32_t
  • #define SCNxLEAST8 'hhx' β€” hexadecimal scanf format for uint_least8_t
  • #define SCNxPTR SCNx16 β€” hexadecimal scanf format for uintptr_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