LLMpediaThe first transparent, open encyclopedia generated by LLMs

stdint.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 56 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted56
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()
stdint.h
Namestdint.h
TypeHeader file
StandardISO/IEC 9899
First appeared1999
PurposeFixed-width integer types and limits

stdint.h

stdint.h is a header file introduced into the C programming language to provide fixed-width integer types, least and fastest integer types, and associated implementation-defined macros for limits and constants. It was standardized alongside the ISO/IEC 9899:1999 revision and is widely implemented in compilers and platforms such as GCC, Clang (compiler), Microsoft Visual C++, Intel C++ Compiler, and libc implementations like glibc, musl, and Newlib. The header addresses portability concerns across architectures including x86, x86-64, ARM architecture, ARM Cortex-M, MIPS architecture, and PowerPC.

Overview

stdint.h defines a family of exact-width integer types (for example, int8_t, int16_t, int32_t, int64_t), minimum-width types (int_least8_t, int_least16_t), fastest minimum-width types (int_fast8_t, int_fast16_t), pointer-sized integers (intptr_t, uintptr_t), greatest-width integers (intmax_t, uintmax_t), and corresponding macros for type limits (INT8_MIN, INT16_MAX, UINT32_MAX) and integer constant macros (INT32_C, UINT64_C). The header complements other standard headers such as stdio.h, stdlib.h, string.h, limits.h, and iso646.h by supplying precise-width integer semantics for systems ranging from embedded platforms used by ARM Cortex-M and AVR microcontrollers to high-performance servers running Linux or Windows. It is commonly referenced in standards-related documents produced by organizations like ISO and IEEE.

Integer types and macros

The exact-width types (int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t) are required only when the implementation provides an integer type with the corresponding width; many compilers on x86-64 and ARM provide all these types. The least-width types (int_least8_t, uint_least8_t, etc.) guarantee at least the specified width and are useful on platforms like SPARC or PowerPC where performance trade-offs exist. Fast types (int_fast8_t, int_fast16_t) map to the type that yields the best speed for at least that width, an approach relevant to compilers such as GCC and Clang (compiler) when targeting ARM Cortex-A series. Pointer-sized types (intptr_t, uintptr_t) correspond to an integer capable of storing a data pointer on platforms such as Windows x64 and POSIX systems. The greatest-width types (intmax_t, uintmax_t) represent the largest integer type provided, often mapping to 64-bit on many systems. Limits macros (e.g., INT32_MIN, UINT64_MAX) provide compile-time constants for bounds checking, while integer constant macros (INT32_C(123), UINT64_C(456)) produce appropriately suffixed literals for use in expressions and initializers across compilers and linkers like those from Intel Corporation and Microsoft.

Implementation details and portability

Implementations of stdint.h vary by C library and toolchain; glibc on Linux and musl target POSIX-like semantics, while Microsoft Visual C++ provides a compatible but historically delayed implementation. On embedded toolchains such as IAR Systems and ARM Keil, stdint.h must reflect the architecture's underlying integer representations and ABI constraints. Endianness concerns arise on ARM (little-endian) versus PowerPC or some MIPS configurations (big-endian) but stdint.h abstracts width rather than byte order. Portability across 16-bit systems, 32-bit systems, and 64-bit systems (examples include MS-DOS, Windows 95/98/ME, and Windows NT families) requires careful use of types like intptr_t for pointer arithmetic and intmax_t for cross-platform serialization in protocols used by IETF standards. Conformance to ISO/IEC 9899 and extensions by POSIX ensure predictable behavior; toolchains may also provide additional typedefs or macros for compatibility with legacy code from ecosystems like BSD variants and Embedded Linux.

Usage examples

Typical usage patterns include explicit-width arrays, network protocol structures, and cross-platform file formats. Example idioms: using uint32_t for 32-bit network headers in implementations of TCP/IP stacks or using int_fast16_t in time-critical inner loops on ARM Cortex-A cores. Serialization routines often use INT32_C and UINT64_C macros when composing portable integer constants for formats specified by organizations like IETF and W3C. Pointer arithmetic and casting to store pointers as integers employ intptr_t and uintptr_t, common in low-level libraries used by SQLite and OpenSSL where deterministic behavior across x86-64 and ARM64 is required.

History and standardization

The addition of stdint.h was formalized in the ISO/IEC 9899:1999 standard ("C99") following discussions within the ISO committee and contributions from compiler vendors and standards bodies including ANSI, POSIX, and implementers from projects like GNU Project. Prior to standardization, projects relied on ad hoc typedefs or platform-specific headers; the C99 standard responded to portability needs voiced by authors of portable systems such as OpenBSD, NetBSD, and FreeBSD. Subsequent revisions of the C standard and widespread compiler adoption, including in GCC and Clang (compiler), solidified stdint.h as a de facto requirement for modern C code, with extensions and clarifications adopted in later technical corrigenda and related ISO working group documents.

stdint.h is often used alongside , , and . The header builds on stdint.h by providing printf/scanf macros like PRId32 and SCNu64 for portable I/O formatting, which is important for interoperability with libraries such as libc, libc++, and runtime environments like POSIX shells. Compatibility layers exist in toolchains and projects including MinGW, Cygwin, and embedded SDKs to provide stdint.h on platforms that lacked it historically. Developers working with mixed C/C++ codebases consider the interaction between stdint.h and C++ headers standardized by ISO/IEC JTC 1/SC 22/WG 14 and WG21 where analogous types are offered in and integrated into C++ standard libraries implemented by vendors like Microsoft, LLVM, and GNU.

Category:C programming language headers