avr-libc: <inttypes.h>: Integer Type conversions

avr-libc 2.1.0 Standard C library for AVR-GCC |

## AVR Libc Home Page |  | ## AVR Libc Development Pages
## Main Page | ## User Manual | ## Library Reference | ## FAQ | ## Example Projects

Loading...
Searching...
No Matches
<inttypes.h>: Integer Type conversions

## 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>.
#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 | 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

## Detailed Description

#include <inttypes.h>
inttypes.h

This header file includes the exact-width integer definitions from `<stdint.h>`, and extends them with additional facilities provided by the implementation.

Currently, the extensions include two additional integer types that could hold a "far" pointer (i.e. a code pointer that can address more than 64 KB), as well as standard names for all printf and scanf formatting options that are supported by the <stdio.h>: Standard IO facilities. As the library does not support the full range of conversion specifiers from ISO 9899:1999, only those conversions that are actually implemented will be listed here.

The idea behind these conversion macros is that, for each of the types defined by <stdint.h>, a macro will be supplied that portably allows formatting an object of that type in printf() or scanf() operations. 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 ".\n",
smallval, longval);
PRId32
#define PRId32
Definition: inttypes.h:138
PRIx8
#define PRIx8
Definition: inttypes.h:202
uint8_t
unsigned char uint8_t
Definition: stdint.h:83
int32_t
signed long int int32_t
Definition: stdint.h:98

## Macro Definition Documentation

## ◆ PRId16

#define PRId16 "d"

decimal printf format for int16_t

## ◆ PRId32

#define PRId32 "ld"

decimal printf format for int32_t

## ◆ PRId8

#define PRId8 "d"

decimal printf format for int8_t

## ◆ PRIdFAST16

#define PRIdFAST16 "d"

decimal printf format for int_fast16_t

## ◆ PRIdFAST32

#define PRIdFAST32 "ld"

decimal printf format for int_fast32_t

## ◆ PRIdFAST8

#define PRIdFAST8 "d"

decimal printf format for int_fast8_t

## ◆ PRIdLEAST16

#define PRIdLEAST16 "d"

decimal printf format for int_least16_t

## ◆ PRIdLEAST32

#define PRIdLEAST32 "ld"

decimal printf format for int_least32_t

## ◆ PRIdLEAST8

#define PRIdLEAST8 "d"

decimal printf format for int_least8_t

## ◆ PRIdPTR

#define PRIdPTR PRId16

decimal printf format for intptr_t

## ◆ PRIi16

#define PRIi16 "i"

integer printf format for int16_t

## ◆ PRIi32

#define PRIi32 "li"

integer printf format for int32_t

## ◆ PRIi8

#define PRIi8 "i"

integer printf format for int8_t

## ◆ PRIiFAST16

#define PRIiFAST16 "i"

integer printf format for int_fast16_t

## ◆ PRIiFAST32

#define PRIiFAST32 "li"

integer printf format for int_fast32_t

## ◆ PRIiFAST8

#define PRIiFAST8 "i"

integer printf format for int_fast8_t

## ◆ PRIiLEAST16

#define PRIiLEAST16 "i"

integer printf format for int_least16_t

## ◆ PRIiLEAST32

#define PRIiLEAST32 "li"

integer printf format for int_least32_t

## ◆ PRIiLEAST8

#define PRIiLEAST8 "i"

integer printf format for int_least8_t

## ◆ PRIiPTR

#define PRIiPTR PRIi16

integer printf format for intptr_t

## ◆ PRIo16

#define PRIo16 "o"

octal printf format for uint16_t

## ◆ PRIo32

#define PRIo32 "lo"

octal printf format for uint32_t

## ◆ PRIo8

#define PRIo8 "o"

octal printf format for uint8_t

## ◆ PRIoFAST16

#define PRIoFAST16 "o"

octal printf format for uint_fast16_t

## ◆ PRIoFAST32

#define PRIoFAST32 "lo"

octal printf format for uint_fast32_t

## ◆ PRIoFAST8

#define PRIoFAST8 "o"

octal printf format for uint_fast8_t

## ◆ PRIoLEAST16

#define PRIoLEAST16 "o"

octal printf format for uint_least16_t

## ◆ PRIoLEAST32

#define PRIoLEAST32 "lo"

octal printf format for uint_least32_t

## ◆ PRIoLEAST8

#define PRIoLEAST8 "o"

octal printf format for uint_least8_t

## ◆ PRIoPTR

#define PRIoPTR PRIo16

octal printf format for uintptr_t

## ◆ PRIu16

#define PRIu16 "u"

decimal printf format for uint16_t

## ◆ PRIu32

#define PRIu32 "lu"

decimal printf format for uint32_t

## ◆ PRIu8

#define PRIu8 "u"

decimal printf format for uint8_t

## ◆ PRIuFAST16

#define PRIuFAST16 "u"

decimal printf format for uint_fast16_t

## ◆ PRIuFAST32

#define PRIuFAST32 "lu"

decimal printf format for uint_fast32_t

## ◆ PRIuFAST8

#define PRIuFAST8 "u"

decimal printf format for uint_fast8_t

## ◆ PRIuLEAST16

#define PRIuLEAST16 "u"

decimal printf format for uint_least16_t

## ◆ PRIuLEAST32

#define PRIuLEAST32 "lu"

decimal printf format for uint_least32_t

## ◆ PRIuLEAST8

#define PRIuLEAST8 "u"

decimal printf format for uint_least8_t

## ◆ PRIuPTR

#define PRIuPTR PRIu16

decimal printf format for uintptr_t

## ◆ PRIx16

#define PRIx16 "x"

hexadecimal printf format for uint16_t

## ◆ PRIX16

#define PRIX16 "X"

uppercase hexadecimal printf format for uint16_t

## ◆ PRIx32

#define PRIx32 "lx"

hexadecimal printf format for uint32_t

## ◆ PRIX32

#define PRIX32 "lX"

uppercase hexadecimal printf format for uint32_t

## ◆ PRIx8

#define PRIx8 "x"

hexadecimal printf format for uint8_t

## ◆ PRIX8

#define PRIX8 "X"

uppercase hexadecimal printf format for uint8_t

## ◆ PRIxFAST16

#define PRIxFAST16 "x"

hexadecimal printf format for uint_fast16_t

## ◆ PRIXFAST16

#define PRIXFAST16 "X"

uppercase hexadecimal printf format for uint_fast16_t

## ◆ PRIxFAST32

#define PRIxFAST32 "lx"

hexadecimal printf format for uint_fast32_t

## ◆ PRIXFAST32

#define PRIXFAST32 "lX"

uppercase hexadecimal printf format for uint_fast32_t

## ◆ PRIxFAST8

#define PRIxFAST8 "x"

hexadecimal printf format for uint_fast8_t

## ◆ PRIXFAST8

#define PRIXFAST8 "X"

uppercase hexadecimal printf format for uint_fast8_t

## ◆ PRIxLEAST16

#define PRIxLEAST16 "x"

hexadecimal printf format for uint_least16_t

## ◆ PRIXLEAST16

#define PRIXLEAST16 "X"

uppercase hexadecimal printf format for uint_least16_t

## ◆ PRIxLEAST32

#define PRIxLEAST32 "lx"

hexadecimal printf format for uint_least32_t

## ◆ PRIXLEAST32

#define PRIXLEAST32 "lX"

uppercase hexadecimal printf format for uint_least32_t

## ◆ PRIxLEAST8

#define PRIxLEAST8 "x"

hexadecimal printf format for uint_least8_t

## ◆ PRIXLEAST8

#define PRIXLEAST8 "X"

uppercase hexadecimal printf format for uint_least8_t

## ◆ PRIxPTR

#define PRIxPTR PRIx16

hexadecimal printf format for uintptr_t

## ◆ PRIXPTR

#define PRIXPTR PRIX16

uppercase hexadecimal printf format for uintptr_t

## ◆ SCNd16

#define SCNd16 "d"

decimal scanf format for int16_t

## ◆ SCNd32

#define SCNd32 "ld"

decimal scanf format for int32_t

## ◆ SCNd8

#define SCNd8 "hhd"

decimal scanf format for int8_t

## ◆ SCNdFAST16

#define SCNdFAST16 "d"

decimal scanf format for int_fast16_t

## ◆ SCNdFAST32

#define SCNdFAST32 "ld"

decimal scanf format for int_fast32_t

## ◆ SCNdFAST8

#define SCNdFAST8 "hhd"

decimal scanf format for int_fast8_t

## ◆ SCNdLEAST16

#define SCNdLEAST16 "d"

decimal scanf format for int_least16_t

## ◆ SCNdLEAST32

#define SCNdLEAST32 "ld"

decimal scanf format for int_least32_t

## ◆ SCNdLEAST8

#define SCNdLEAST8 "hhd"

decimal scanf format for int_least8_t

## ◆ SCNdPTR

#define SCNdPTR SCNd16

decimal scanf format for intptr_t

## ◆ SCNi16

#define SCNi16 "i"

generic-integer scanf format for int16_t

## ◆ SCNi32

#define SCNi32 "li"

generic-integer scanf format for int32_t

## ◆ SCNi8

#define SCNi8 "hhi"

generic-integer scanf format for int8_t

## ◆ SCNiFAST16

#define SCNiFAST16 "i"

generic-integer scanf format for int_fast16_t

## ◆ SCNiFAST32

#define SCNiFAST32 "li"

generic-integer scanf format for int_fast32_t

## ◆ SCNiFAST8

#define SCNiFAST8 "hhi"

generic-integer scanf format for int_fast8_t

## ◆ SCNiLEAST16

#define SCNiLEAST16 "i"

generic-integer scanf format for int_least16_t

## ◆ SCNiLEAST32

#define SCNiLEAST32 "li"

generic-integer scanf format for int_least32_t

## ◆ SCNiLEAST8

#define SCNiLEAST8 "hhi"

generic-integer scanf format for int_least8_t

## ◆ SCNiPTR

#define SCNiPTR SCNi16

generic-integer scanf format for intptr_t

## ◆ SCNo16

#define SCNo16 "o"

octal scanf format for uint16_t

## ◆ SCNo32

#define SCNo32 "lo"

octal scanf format for uint32_t

## ◆ SCNo8

#define SCNo8 "hho"

octal scanf format for uint8_t

## ◆ SCNoFAST16

#define SCNoFAST16 "o"

octal scanf format for uint_fast16_t

## ◆ SCNoFAST32

#define SCNoFAST32 "lo"

octal scanf format for uint_fast32_t

## ◆ SCNoFAST8

#define SCNoFAST8 "hho"

octal scanf format for uint_fast8_t

## ◆ SCNoLEAST16

#define SCNoLEAST16 "o"

octal scanf format for uint_least16_t

## ◆ SCNoLEAST32

#define SCNoLEAST32 "lo"

octal scanf format for uint_least32_t

## ◆ SCNoLEAST8

#define SCNoLEAST8 "hho"

octal scanf format for uint_least8_t

## ◆ SCNoPTR

#define SCNoPTR SCNo16

octal scanf format for uintptr_t

## ◆ SCNu16

#define SCNu16 "u"

decimal scanf format for uint16_t

## ◆ SCNu32

#define SCNu32 "lu"

decimal scanf format for uint32_t

## ◆ SCNu8

#define SCNu8 "hhu"

decimal scanf format for uint8_t

## ◆ SCNuFAST16

#define SCNuFAST16 "u"

decimal scanf format for uint_fast16_t

## ◆ SCNuFAST32

#define SCNuFAST32 "lu"

decimal scanf format for uint_fast32_t

## ◆ SCNuFAST8

#define SCNuFAST8 "hhu"

decimal scanf format for uint_fast8_t

## ◆ SCNuLEAST16

#define SCNuLEAST16 "u"

decimal scanf format for uint_least16_t

## ◆ SCNuLEAST32

#define SCNuLEAST32 "lu"

decimal scanf format for uint_least32_t

## ◆ SCNuLEAST8

#define SCNuLEAST8 "hhu"

decimal scanf format for uint_least8_t

## ◆ SCNuPTR

#define SCNuPTR SCNu16

decimal scanf format for uintptr_t

## ◆ SCNx16

#define SCNx16 "x"

hexadecimal scanf format for uint16_t

## ◆ SCNx32

#define SCNx32 "lx"

hexadecimal scanf format for uint32_t

## ◆ SCNx8

#define SCNx8 "hhx"

hexadecimal scanf format for uint8_t

## ◆ SCNxFAST16

#define SCNxFAST16 "x"

hexadecimal scanf format for uint_fast16_t

## ◆ SCNxFAST32

#define SCNxFAST32 "lx"

hexadecimal scanf format for uint_fast32_t

## ◆ SCNxFAST8

#define SCNxFAST8 "hhx"

hexadecimal scanf format for uint_fast8_t

## ◆ SCNxLEAST16

#define SCNxLEAST16 "x"

hexadecimal scanf format for uint_least16_t

## ◆ SCNxLEAST32

#define SCNxLEAST32 "lx"

hexadecimal scanf format for uint_least32_t

## ◆ SCNxLEAST8

#define SCNxLEAST8 "hhx"

hexadecimal scanf format for uint_least8_t

## ◆ SCNxPTR

#define SCNxPTR SCNx16

hexadecimal scanf format for uintptr_t

## Typedef Documentation

## ◆ int_farptr_t

typedef int32_t int_farptr_t

signed integer type that can hold a pointer > 64 KB

## ◆ uint_farptr_t

typedef uint32_t uint_farptr_t

unsigned integer type that can hold a pointer > 64 KB