c-standard-library
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| c-standard-library [February 20, 2026 at 02:23] – yanevskiv | c-standard-library [May 14, 2026 at 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | # C standard library | ||
| + | **C standard library** is one library that's always linked by default when you compile C programs. | ||
| + | |||
| + | To use the library, a set of headers is offered which you can include by default. | ||
| + | |||
| + | For example, `< | ||
| + | |||
| + | - `< | ||
| + | - `< | ||
| + | |||
| + | ```c | ||
| + | // Compile: gcc main.c -o program | ||
| + | // Run: | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | int main() | ||
| + | { | ||
| + | printf(" | ||
| + | |||
| + | return EXIT_SUCCESS; | ||
| + | } | ||
| + | ``` | ||
| + | |||
| + | |||
| + | ## Headers | ||
| + | |||
| + | - [[assert.h]] | ||
| + | - [[complex.h]] | ||
| + | - [[ctype.h]] | ||
| + | - [[errno.h]] | ||
| + | - [[fenv.h]] | ||
| + | - [[float.h]] | ||
| + | - [[inttypes.h]] | ||
| + | - [[iso646.h]] | ||
| + | - [[limits.h]] | ||
| + | - [[locale.h]] | ||
| + | - [[math.h]] | ||
| + | - [[setjmp.h]] | ||
| + | - [[signal.h]] | ||
| + | - [[stdalign.h]] | ||
| + | - [[stdarg.h]] | ||
| + | - [[stdatomic.h]] | ||
| + | - [[stdbit.h]] | ||
| + | - [[stdbool.h]] | ||
| + | - [[stdckdint.h]] | ||
| + | - [[stddef.h]] | ||
| + | - [[stdint.h]] | ||
| + | - [[stdio.h]] | ||
| + | - [[stdlib.h]] | ||
| + | - [[stdmchar.h]] | ||
| + | - [[stdnoreturn.h]] | ||
| + | - [[string.h]] | ||
| + | - [[tgmath.h]] | ||
| + | - [[thread.h]] | ||
| + | - [[time.h]] | ||
| + | - [[uchar.h]] | ||
| + | - [[wchar.h]] | ||
| + | - [[wctype.h]] | ||
| + | |||
| + | |||
| + | ## What are headers for? | ||
| + | Headers commonly define various constants (`#define`) e.g. `< | ||
| + | ```bash | ||
| + | $ grep -e EXIT_SUCCESS < / | ||
| + | #define EXIT_SUCCESS | ||
| + | ``` | ||
| + | |||
| + | They also commonly declare various function calls e.g. `< | ||
| + | ```bash | ||
| + | $ grep -e ' | ||
| + | extern int printf (const char *__restrict __format, ...); | ||
| + | ``` | ||
| + | |||
| + | And they also declare various `struct`s, `union`s, and `typedef`s | ||
| + | |||
| + | |||
| + | ## Paths | ||
| + | All headers all live in `/ | ||
| + | |||
| + | - `/ | ||
| + | |||
| + | The library itself lives in `/usr/lib`. It actually comes in two flavors: | ||
| + | |||
| + | - `/ | ||
| + | - `/ | ||
| + | |||
| + | ## Static vs dynamic | ||
| + | |||
| + | |||
| + | ## Austerity | ||
| + | Compared to standard libraries of modern programming languages -- such as Rust, C++17, Python, JavaScript etc. -- you'll find the C standard library frustratingly barren and austere. | ||
| + | |||
| + | It contains almost nothing! | ||
| + | |||
| + | Furthermore, | ||
| + | |||
| + | ## What's missing? | ||
| + | ### No data structures | ||
| + | No maps. No vectors. No lists or trees. Nothing. | ||
| + | |||
| + | If you want something like C++'s `std:: | ||
| + | ``` | ||
| + | typedef struct _vector_t { | ||
| + | void* v_data; | ||
| + | size_t v_capacity; | ||
| + | size_t v_size; | ||
| + | } vector_t; | ||
| + | ``` | ||
| + | But many data structures common in higher programming languages -- like C++'s `std::map` or Python' | ||
| + | |||
| + | While C might be conceptually the fastest programming language in existence (you' | ||
| + | |||
| + | ### No: string manipulation | ||
| + | |||
| + | ### No: serialization | ||
| + | No JSON. No YAML. No XML. No ini files. Nothing. | ||
| + | |||
| + | ### No: filesystem | ||
| + | No directory traversal. No file permission. | ||
| + | |||
| + | ### No: web | ||
| + | No sockets. No web servers. No requests. Nothing. | ||
| + | |||
| + | ### No: unicode | ||
| + | No emojis. No CJK, arabic. | ||
| + | |||
| + | ### No: async or multithreading | ||
| + | |||
| + | ## Hosted vs freestanding | ||
| + | |||
| + | |||
| + | ## Links | ||
| + | |||
| + | - https:// | ||
| + | - https:// | ||
| + | - https:// | ||
