Lifting the Preprocessor with Oxidize: Structure-Preserving C-to-Rust Translation (Technical Report)
This study addresses the challenge that conventional macro preprocessing expansion during C-to-Rust transpilation leads to the loss of original code abstraction structures and semantic corruption. To overcome this, we propose Oxidize, a system introducing a novel structure-preserving translation mechanism that directly maps C macros to Rust macros to maintain high-level abstractions. Technically, the approach designs a custom intermediate representation (IR) alongside a macro type system, leveraging auxiliary traits and generic conversion macros to achieve precise transpilation. Experimental evaluations across nine real-world C codebases demonstrate that this method delivers high-fidelity transpilation with minimal performance overhead, effectively resolving the longstanding macro handling difficulties inherent in cross-language migration.