LLMpediaThe first transparent, open encyclopedia generated by LLMs

inttypes.h

Generated by GPT-5-mini
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Parent: C99 Hop 4
Expansion Funnel Raw 53 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted53
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()

inttypes.h inttypes.h is a C header specified by the ISO/IEC 9899:1999 (C99) standard that supplements stdint.h by providing facilities for formatted input and output, integer constant macros, and additional integer-related types and functions. It is widely implemented in C libraries such as the GNU C Library, musl libc, and BSD libc derivatives, and is used across projects from Linux kernel userspace utilities to embedded systems like Arduino ports. The header interacts with standards and organizations including ISO/IEC JTC 1/SC 22 and toolchains such as GCC and Clang.

Overview

inttypes.h complements the fixed-width integer types introduced by stdint.h by defining macros and functions that standardize printing, scanning, and constant expression creation for types such as the exact-width and least-width integers. The header is referenced in standardization work by ISO/IEC JTC 1/SC 22 and implemented in mainstream runtime environments like the GNU C Library and musl libc; it also appears in operating system userlands including Linux, FreeBSD, and NetBSD. Adoption in compiler toolchains like GCC, Clang, and Intel C Compiler ensures consistent cross-platform behavior for portable C programs.

Fixed-width integer types

inttypes.h itself does not redefine the basic fixed-width typedefs; those are declared in stdint.h and include types such as int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, and uint64_t when the implementation provides exact-width representations. Implementations used in environments like Windows NT, macOS, and embedded RTOS platforms such as FreeRTOS and Zephyr Project may expose additional typedefs from stdint.h that inttypes.h expects. For extended-width or minimum-width types the header interoperates with types defined for POSIX-compliant systems, including types used by OpenBSD and DragonFly BSD.

Format conversion macros

inttypes.h defines format macros that map integer types to corresponding printf and scanf conversion specifiers so code can portably print and read fixed-width and greatest-width integers. Examples include PRId32, PRIu64, SCNi16, and SCNxFAST32, which expand to literal format strings used with functions such as printf and scanf provided by libraries like the GNU C Library, musl libc, and Newlib. These macros are essential in cross-platform projects such as SQLite, OpenSSL, and LLVM components where consistent formatting across GCC, Clang, and platform ABIs (for example x86-64 and ARM64) is required. The mapping accounts for platform-specific width variations influenced by ABIs like the System V AMD64 ABI and conventions used by Microsoft Visual C++. Using PRIdMAX and PRIuMAX ensures correct formatting for types like intmax_t and uintmax_t across diverse environments including Solaris and AIX.

Integer constant macros

To facilitate portable integer literal definitions, inttypes.h declares macros such as INT64_C, UINT32_C, and INTMAX_C that append appropriate suffixes to integer constants so they have the intended width and signedness on a given implementation. Projects targeting platforms ranging from Raspberry Pi boards to enterprise servers running IBM AIX rely on these macros to create compile-time constants with predictable types. These constant macros are referenced in standards discussions by ISO/IEC committees and are commonly used in cross-platform codebases including glibc tests, Musl conformance suites, and embedded firmware stacks supported by toolchains like ARM Compiler and IAR Embedded Workbench.

inttypes.h declares functions and types that complement formatting macros and fixed-width types, notably imaxdiv and strtoimax/strtoumax which operate on intmax_t and uintmax_t types. These functions interoperate with standard library facilities such as printf/scanf families and conversion functions defined in stdlib.h and are used in system libraries for parsing and arithmetic across platforms like NetBSD, OpenBSD, and vendor runtimes from Microsoft. Implementations also coordinate with locale and I/O behaviors specified in standards overseen by organizations like ISO and influenced by platform C runtimes deployed in projects such as BusyBox and GNU Coreutils.

Portability and implementation notes

Portability concerns addressed by inttypes.h include differences in integer widths and ABI conventions across architectures like x86, ARM, PowerPC, and MIPS. Compiler and library combinations—GCC with glibc, Clang with libc++/musl libc, or proprietary toolchains—must correctly expand PRIx and SCN macros to match the implementation-defined representations and calling conventions defined by standards such as the System V ABI or platform-specific ABIs like Microsoft x64 calling convention. Some platforms historically lacked exact-width types (e.g., certain DSPs or legacy systems), so inttypes.h macros and functions degrade gracefully or are omitted, a behavior documented in porting guides from projects such as LLVM and GNU Autotools based software. Developers targeting heterogeneous environments—servers, mobile devices like iPhone OS builds, or embedded controllers—should test format macros and INTMAX constant macros with the compilers and runtimes used in continuous integration systems such as Jenkins or GitHub Actions to ensure consistent behavior.

Category:C (programming language) headers