Sp.h 是 C 语言应有的标准库。
sp.h: Fixing C by giving it a high quality, ultra portable standard library

原始链接: https://spader.zone/sp/

**sp.h** 是一个包含 15,000 行代码的 C99 单头文件库,旨在通过提供直接对接系统调用而非依赖 `libc` 的可移植标准库,来实现 C 语言的现代化。 该项目摒弃了作者认为“有害”的标准库惯例,特别是基于 `FILE*` 的 I/O、隐式全局状态以及以空字符结尾的字符串。取而代之的是: * **显式内存管理:** 程序通过显式的分配器结构来管理自身内存。 * **指针加长度的字符串:** 使用 `sp_str_t` 代替以空字符结尾的字符串,以提高性能、安全性和易用性。 * **可移植性:** 该库与平台无关,可在 Windows、macOS、Linux 和 WASM 上运行,同时保持代码的可读性和易修改性。 该库强调透明度和显式性,要求开发者手动处理错误和内存分配。虽然它并非为 SIMD 等微优化而设计,但专注于高层架构优势,例如零拷贝 I/O。归根结底,`sp.h` 旨在保留 C 语言的简洁性和通用兼容性,同时剔除陈旧的冗余,为系统编程提供了一种现代、可读且高度可移植的替代方案。

相关文章

原文

Over the past year, I’ve been working on fixing C by giving it a high quality, ultra portable standard library. It is not a simple wrapper on top of libc; it doesn’t depend on libc except when required to by the platform. To my knowledge, there is nothing like it.

The library is called sp.h. It’s a 15,000 line, single header library written in plain C99. You can find the source code on GitHub, which includes the library itself, lots of example programs, and half a dozen baseball libraries which extend the core. If you prefer to read a few examples and look through the source, head to GitHub first. Otherwise, let’s get on with the pitch!

联系我们 contact @ memedata.com