The standard library is part of the language standard (C17 clause 7). Each header declares
related functions, types and macros. A header is named in a
#include directive and need
not be an actual file.
Headers
The clause numbers are from C17, whose library clauses are numbered in alphabetical order of the header.
| Header | Provides | Since | Clause |
|---|---|---|---|
<assert.h> | The assert macro | C89 | 7.2 |
<complex.h> | Complex arithmetic | C99 | 7.3 |
<ctype.h> | Character classification and conversion | C89 | 7.4 |
<errno.h> | The errno error indicator | C89 | 7.5 |
<fenv.h> | The floating-point environment | C99 | 7.6 |
<float.h> | Limits of the floating types | C89 | 7.7 |
<inttypes.h> | Format macros for <stdint.h> types, and conversions | C99 | 7.8 |
<iso646.h> | Alternative spellings of operators, such as and and or | C95 | 7.9 |
<limits.h> | Limits of the integer types | C89 | 7.10 |
<locale.h> | Localisation | C89 | 7.11 |
<math.h> | Mathematical functions | C89 | 7.12 |
<setjmp.h> | Non-local jumps with setjmp and longjmp | C89 | 7.13 |
<signal.h> | Signal handling | C89 | 7.14 |
<stdalign.h> | Macros for alignas and alignof; deprecated in C23 | C11 | 7.15 |
<stdarg.h> | Variable arguments | C89 | 7.16 |
<stdatomic.h> | Atomic types and operations | C11 | 7.17 |
<stdbit.h> | Bit and byte utilities | C23 | C23 |
<stdbool.h> | Macros for bool, true and false; deprecated in C23 | C99 | 7.18 |
<stdckdint.h> | Checked integer arithmetic: ckd_add, ckd_sub, ckd_mul | C23 | C23 |
<stddef.h> | Common definitions: size_t, ptrdiff_t, NULL, offsetof | C89 | 7.19 |
<stdint.h> | Fixed-width integer types | C99 | 7.20 |
<stdio.h> | Input and output | C89 | 7.21 |
<stdlib.h> | Memory allocation, conversions, sorting, program exit | C89 | 7.22 |
<stdnoreturn.h> | The noreturn macro; deprecated in C23 | C11 | 7.23 |
<string.h> | String and memory functions | C89 | 7.24 |
<tgmath.h> | Type-generic maths macros | C99 | 7.25 |
<threads.h> | Threads, mutexes and condition variables | C11 | 7.26 |
<time.h> | Date and time | C89 | 7.27 |
<uchar.h> | Unicode character types and conversions | C11 | 7.28 |
<wchar.h> | Wide character input, output and strings | C95 | 7.29 |
<wctype.h> | Wide character classification | C95 | 7.30 |
Headers from other standards, such as POSIX’s <unistd.h>, are not part of
the C standard.
Headers by standard
| Standard | Headers added |
|---|---|
| C89 | assert.h, ctype.h, errno.h, float.h, limits.h, locale.h, math.h, setjmp.h, signal.h, stdarg.h, stddef.h, stdio.h, stdlib.h, string.h, time.h |
| C95 | iso646.h, wchar.h, wctype.h |
| C99 | complex.h, fenv.h, inttypes.h, stdbool.h, stdint.h, tgmath.h |
| C11 | stdalign.h, stdatomic.h, stdnoreturn.h, threads.h, uchar.h |
| C23 | stdbit.h, stdckdint.h |
Freestanding implementations
A conforming freestanding implementation need provide only a small part of the
library, and __STDC_HOSTED__ is 0 (C17 clause 4). In C17 these are:
<float.h>, <iso646.h>, <limits.h>,
<stdalign.h>, <stdarg.h>, <stdbool.h>,
<stddef.h>, <stdint.h> and
<stdnoreturn.h>.
These headers hold types, macros and little else, so they need no operating system.
Optional parts
| Feature | Macro | Status |
|---|---|---|
| Complex types | __STDC_NO_COMPLEX__ if absent | Mandatory in C99, optional from C11 |
Atomics, <stdatomic.h> | __STDC_NO_ATOMICS__ if absent | Optional, added in C11 |
Threads, <threads.h> | __STDC_NO_THREADS__ if absent | Optional, added in C11 |
| Variable length arrays | __STDC_NO_VLA__ if absent | Mandatory in C99, optional from C11 |
| Bounds-checking interfaces (Annex K) | __STDC_LIB_EXT1__ if present | Optional, added in C11 |
| IEC 60559 floating point (Annex F) | __STDC_IEC_559__ if present | Optional, added in C99 |
| Decimal floating types | __STDC_IEC_60559_DFP__ if present | Optional, added in C23 |
Annex K defines checked versions of several functions, such as strcpy_s. To
see them, a program defines __STDC_WANT_LIB_EXT1__ to 1 before including the
header (C17 K.3.1.1). Their support in common implementations is limited.
Names reserved by the library
Identifiers declared by a header are reserved to it, and some names are reserved for the
library’s future use (C17 7.31). See
Reserved identifiers.
Library functions may be implemented as macros, so
(strlen)(s) forces the function to be called.