Working toward a safer standard library for the next generation
NextStd is an experimental effort to explore safer, well-defined, and modern alternatives to traditional C standard library components. The project focuses on correctness, explicit behavior, and performance, while remaining practical for real-world systems and embedded use.
This is a work in progress. APIs, guarantees, and scope may evolve as the project matures. All core logic is backed by Rust, safely exposed to C via FFI.
A memory-safe, crash-proof alternative to <stdio.h> that completely eliminates
format string vulnerabilities. It uses C11 _Generic routing to automatically
detect data types at compile time.
- Output (
ns_print,ns_println): Safely printsint,float,double,char*, and custom NextStd types without%dor%sspecifiers. - Input (
ns_read): Safely readsint,float, anddouble. It gracefully defaults to0on invalid user input instead of panicking, and includes strictNULLpointer safeguards.
A modern alternative to standard C strings (char*) designed to eliminate
buffer overflows,
- Small String Optimization (SSO): Strings under 24 bytes are allocated directly on the stack, resulting in zero heap fragmentation (ideal for embedded constraints).
- Automatic Heap Scaling: Strings 24 bytes and larger seamlessly scale to the heap, with memory lifecycles safely managed by the Rust backend.
- Core Functions:
ns_string_new(),ns_string_free()
NextStd bridges the gap between modern safety and legacy compatibility:
- Rust Backend: Handles memory allocation, bounds checking, and core logic.
- C Frontend: Exposes a clean, macro-driven API that feels completely native to C developers.
