Feed

C

C programming discussions covering systems programming, memory management, and embedded development. Our digest aggregates undefined behavior, compiler optimizations, and embedded systems from developer communities.

Articles from the last 30 days

Converting a $3.88 analog clock from Walmart into a ESP8266-based Wi-Fi clock
01Monday, February 9, 2026

Converting a $3.88 analog clock from Walmart into a ESP8266-based Wi-Fi clock

This project details the creation of an NTP-synchronized analog clock using a WEMOS D1 Mini ESP8266 module. By modifying a standard quartz movement, specifically the Lavet stepping motor, the creator enables the ESP32 to drive the clock hands via bipolar pulses. The system connects to a Network Time Protocol server every 15 minutes to maintain high accuracy and automatically adjusts for daylight savings time. To solve the issue of position tracking during power failures, the project utilizes a Microchip 47L04 EERAM IC to store the hand positions in real-time. Additionally, the ESP8266 serves a web interface for initial configuration and status monitoring, utilizing technologies like SVG and HTML Canvas to visualize the clock's readout.

Sources:Hacker News568 pts
Thoughts on Generating C
02Monday, February 9, 2026

Thoughts on Generating C

In this technical analysis, the author shares practical techniques for using C as a target language for compilers and generators. Central to the discussion is the use of 'static inline' functions to enable efficient data abstraction without performance penalties, ensuring that abstraction costs are eliminated during compilation. The author also advocates for avoiding implicit integer conversions by using explicit cast functions and leveraging single-member structs to wrap raw pointers, which aids in type safety and memory management. Furthermore, the summary covers manual register allocation for handling complex ABIs and tail calls, and the reliability of modern compilers in optimizing 'memcpy' for unaligned memory access. While acknowledging limitations like lack of stack control and debugging difficulties, the author highlights that well-structured generated C code can be nearly bug-free once it successfully type-checks.

Defer available in gcc and clang
03Sunday, February 15, 2026

Defer available in gcc and clang

The C programming language is adopting the 'defer' feature via TS 25755, now integrated into clang-22 and available in older gcc versions via workarounds. This mechanism simplifies cleanup handling, preventing resource leaks and reducing complex code paths for mutex unlocking and memory deallocation without requiring external libraries or risking security vulnerabilities.

Pure C, CPU-only inference with Mistral Voxtral Realtime 4B speech to text model
04Thursday, February 5, 2026

Pure C, CPU-only inference with Mistral Voxtral Realtime 4B speech to text model

This project provides a standalone C implementation of the inference pipeline for Mistral AI's Voxtral Realtime 4B, a 4-billion parameter speech-to-text model. By eliminating external dependencies beyond the C standard library, it allows for high-performance audio transcription without a Python runtime or CUDA toolkit. Key features include Metal GPU acceleration for Apple Silicon, a streaming C API with chunked audio processing, and memory-mapped weight loading from safetensors. The implementation supports multiple backends including MPS and BLAS, while featuring a rolling KV cache to handle unlimited audio length. Additionally, a self-contained Python reference implementation is included to enhance accessibility and understanding of the model's architecture.

Sources:Hacker News270 pts
zclaw: personal AI assistant in under 888 KB, running on an ESP32
05Monday, February 16, 2026

zclaw: personal AI assistant in under 888 KB, running on an ESP32

zclaw is an ultra-lightweight AI personal assistant written in C for ESP32. With a firmware footprint under 888 KiB, it integrates ESP-IDF, Wi-Fi, and TLS. It supports GPT, Anthropic, and OpenRouter for natural language GPIO control, scheduling, and custom tools, featuring Telegram integration and persistent memory for efficient microcontroller-based automation.

Sources:Hacker News253 pts
I write games in C (yes, C)
06Saturday, February 7, 2026

I write games in C (yes, C)

In this personal reflection on software development, the author explains their unconventional choice of using vanilla C for independent game development. Despite the dominance of C++, C#, and modern engines, the author prioritizes reliability, long-term availability, and extreme simplicity. They argue that C offers unmatched portability across operating systems and consoles while maintaining high performance and exceptionally fast compilation speeds, which is crucial for maintaining developer focus. The author critiques C++ for its overwhelming complexity and slow build times, and rejects OOP-heavy languages like Java and C# due to their rigid data-code coupling. While acknowledging that C is 'a sharp knife' that requires careful handling, the author concludes that its stability and extensive tooling make it the most sustainable choice for their creative workflow, ensuring their games remain playable and maintainable for decades to come without being tethered to fleeting technologies like Flash.

Sources:Hacker News227 pts
Show HN: Sameshi – a ~1200 Elo chess engine that fits within 2KB
07Saturday, February 14, 2026

Show HN: Sameshi – a ~1200 Elo chess engine that fits within 2KB

sameshi.h is a minimal chess engine implemented in C, utilizing a 120-cell mailbox board and Negamax search with alpha-beta pruning. Despite missing complex rules like castling or promotion, it achieves approximately 1170 Elo through material-based evaluation and capture-first move ordering, as validated by 240 games against Stockfish.

Sources:Hacker News209 pts
Nintendo DS code editor and scriptable game engine
08Saturday, January 31, 2026

Nintendo DS code editor and scriptable game engine

The project introduces a scriptable 3D game engine for the Nintendo DS console, developed in C using libnds. It empowers users to write and execute code directly on the console, replicating a handheld development experience. The engine utilizes the DS's 3D hardware to achieve 60 FPS rendering with a dual-screen setup: a touch-based code editor on the bottom and a real-time 3D viewport on the top. Its custom scripting language supports variables, loops, conditionals, and hardware-specific input registers. The engine features a software-rendered UI and a simplified execution model that processes scripts line-by-line. A key implementation detail is the use of GL_MODELVIEW for camera management and GL_QUADS for geometry. The developer provides a pre-built ROM and a pong game example to demonstrate the engine's capabilities in a retro-programming context.

Sources:Hacker News155 pts
Tiny C Compiler
09Saturday, February 7, 2026

Tiny C Compiler

The Tiny C Compiler (TCC), created by Fabrice Bellard, is a remarkably compact and high-performance C compiler designed for efficiency and speed. Its primary strengths lie in its small footprint—approximately 100KB for the x86 version—and its ability to generate machine code significantly faster than traditional tools like GCC. TCC is notable for supporting C scripts, allowing developers to execute C source files directly from the command line without manual linking. Furthermore, it offers features such as an optional memory and bound checker for safe execution and can be used as a backend for dynamic code generation via libtcc. Despite its size, it aims for ISO C99 compliance and can successfully compile itself, demonstrating its robustness for system tasks and rapid development.

Sources:Hacker News141 pts
Coccinelle: Source-to-source transformation tool
10Saturday, February 21, 2026

Coccinelle: Source-to-source transformation tool

Coccinelle is an open-source tool designed for C source code transformations and refactoring. It enables programmers to perform complex, style-preserving changes using the Semantic Patch Language (SmPL). Developed by Inria, the repository provides installation guides, usage instructions for the spatch tool, and guidelines for contributing via signed patches.

Sources:Hacker News110 pts
picol: A Tcl interpreter in 500 lines of code
11Monday, February 16, 2026

picol: A Tcl interpreter in 500 lines of code

Picol is a minimalist Tcl-like interpreter written in just 500 lines of C. It features a hand-written parser, support for variables, procedures, recursion, and control structures like if and while. Designed for educational purposes, it archives a clean C programming style while remaining functional enough to run non-trivial programs.

Sources:Hacker News110 pts
Supercazzola - Generate spam for web scrapers
12Saturday, February 14, 2026

Supercazzola - Generate spam for web scrapers

Supercazzola is a scraper tar pit designed to poison web crawlers and greedy AI bots that ignore robots.txt. Written in C using libevent, it dynamically generates an infinite graph of random HTML pages via Markov chains, effectively trapping and wasting the resources of malicious automated scrapers.

Sources:Lobsters41 pts
The little bool of doom
13Monday, February 9, 2026

The little bool of doom

In this technical deep dive, the author explores a compilation failure of chocolate-doom during the Fedora Linux 42 mass rebuild. The issue stems from the transition to the C23 standard, where 'false' and 'true' became keywords, clashing with the engine's custom boolean enum. Upon attempting to fix this by using the standard C99 _Bool type, the engine suffered a logical failure during sprite initialization. Investigation revealed that the engine relied on 'memset' to initialize memory to -1. While an enum comparison would check if the value equals 0, the _Bool optimization in GCC results in logic where a value of 255 (from -1) is treated as both true and false simultaneously. This behavior is identified as Undefined Behaviour under the C99 standard, specifically regarding invalid object representations of boolean types.

Sources:Lobsters31 pts
Parse, Don’t Validate AKA Some C Safety Tips
14Sunday, February 22, 2026

Parse, Don’t Validate AKA Some C Safety Tips

This guide explains the 'Parse, Don't Validate' technique in C to enhance software security. By converting untrusted input into opaque types at system boundaries, developers can leverage C's type safety to prevent logic errors, parameter swapping, and common vulnerabilities, ensuring that internal functions only process pre-verified, structured data.

Sources:Lobsters28 pts
(Un)portable defer in C
15Thursday, February 5, 2026

(Un)portable defer in C

This technical article explores the implementation of the defer statement in the C programming language, a feature common in modern languages like Zig but currently missing from the C standard. The author examines various non-portable workarounds, including GCC nested functions with the cleanup attribute, Clang blocks, and Windows-specific structured exception handling. Each method is evaluated for its trade-offs, particularly the security risks of executable stacks associated with GCC trampolines. The article also covers alternative approaches using long jumps, for-loop hacks, and custom stack-based systems for LIFO resource management. Ultimately, the author recommends a simplified GCC/Clang macro using the cleanup attribute for most use cases, emphasizing that while portability remains a challenge, functional defer mechanisms are achievable in current C environments.

Sources:Lobsters25 pts