LATEST ARTICLES BY Ugochukwu Chizaram Omumusinachi

Latest articles curated daily by Ugochukwu Chizaram Omumusinachi.

#[cfg] Conditional Compilation in Rust

By Ugochukwu Chizaram Omumusinachi. Updated Thu Jan 16 2025

Have you ever built a cross-compatible game or CLI tool or the simple Russian Roulette game, I have as the banner for this article?

Well if you are wondering how I can target each operating system, sit back as I explain the wonders of conditional compilation and how it is done in Rust.

#[cfg]  Conditional Compilation in Rust

If you have ever built cross-compatible software you would not need this explanation; but for the rest of us. Conditional compilation is simply compiling only parts of code needed based on some given conditions