What is it about?

Many systems today still run on legacy code written in C — a language that’s powerful, but risky when it comes to memory safety. Rust offers a safer alternative, but converting C code to Rust is not straightforward, especially when C macros are involved. Macros are like little programs that modify code before it’s compiled — and most existing tools simply erase them during translation, making the resulting code harder to understand and maintain. Our work introduces Oxidize, a new tool that preserves macro structure when translating C code to Rust. Instead of flattening everything, Oxidize intelligently decides which macros to keep and which ones to expand. We show that real-world macros can be translated directly into idiomatic Rust — improving safety without sacrificing readability or abstraction. This opens the door to safer and more secure software modernization, especially in embedded and safety-critical systems where macro-heavy C code is common.

Featured Image

Why is it important?

This work addresses a major gap in automated software migration: existing C-to-Rust tools ignore macros, a key feature in embedded and system-level code. By preserving macro structure and semantics, Oxidize allows developers to modernize large legacy codebases without losing readability or maintainability. This is especially timely as government and industry initiatives push for memory-safe programming — and demand tools that can bridge the gap between unsafe legacy code and safer modern languages like Rust. Our approach helps accelerate this transition in safety-critical domains such as robotics, automotive, and defense.

Perspectives

As someone working on operating systems and system-level tooling, I’ve seen firsthand how difficult it is to bring safer programming languages like Rust into environments that rely heavily on legacy C code. This project started as a student-driven exploration, and I was impressed by how quickly we were able to go from a theoretical challenge to a working prototype that handles real-world macros gracefully. I believe tools like Oxidize can make a real difference in helping teams modernize their software without rewriting everything from scratch — and this project reflects my broader interest in building bridges between existing systems and safer, more maintainable solutions.

Antonio Paolillo
Vrije Universiteit Brussel

Read the Original

This page is a summary of: Towards Macro-Aware C-to-Rust Transpilation (WIP), June 2025, ACM (Association for Computing Machinery),
DOI: 10.1145/3735452.3735535.
You can read the full text:

Read

Contributors

The following have contributed to this page