Towards Macro-Aware C-to-Rust Transpilation (WIP)
The automatic translation of legacy C code to Rust presents significant challenges, particularly in handling preprocessor macros. C macros introduce metaprogramming constructs that operate at the text level, outside of C's syntax tree, making their direct translation to Rust non-trivial. Existing transpilers --- source-to-source compilers --- expand macros before translation, sacrificing their abstraction and reducing code maintainability. In this work, we introduce Oxidize, a macro-aware C-to-Rust transpilation framework that preserves macro semantics by translating C macros into Rust-compatible constructs while selectively expanding only those that interfere with Rust's stricter semantics. We evaluate our techniques on a small-scale study of real-world macros and find that the majority can be safely and idiomatically transpiled without full expansion.
Authors
- Ken Hasselmann (ORCID: https://orcid.org/0000-0002-8196-9889)
- Antonio Paolillo (ORCID: https://orcid.org/0000-0001-6608-6562)
- Robbe De Greef
- Attilio Discepoli
- Esteban Aguililla Klein (ORCID: https://orcid.org/0009-0007-0987-1186)
- Théo Engels
Institutions
- Université Libre de Bruxelles (BE)
- Vrije Universiteit Brussel (BE)
- Royal Military Academy (BE)
Publication Details
- Published
- 2025-06-13
- DOI
- https://doi.org/10.1145/3735452.3735535
- Citations
- 1
- Primary Topic
- VLSI and Analog Circuit Testing
- Type
- article
- Field-Weighted Citation Impact
- 2.27
Funders
- Department for Environment, Food and Rural Affairs, UK Government