How do I apply macros only on release?

I'm currently working on a game using the Amethyst engine.
I want the log to be displayed in the console when debugging, but I want it to be displayed in the GUI window only when releasing.

I want this macro to be deployed only in the release build. How do I do this?

#![windows_subsystem = "windows"]

#[cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

I'm not sure if this works as a outter attribute. But as inner attribute, it conditionally set the "#[windows_subsystem="windows"]" when it's release profile

1 Like

I ran the code in the release build, but I got the console.

if cfg!(debug_assertions) {
    println!("debug");
} else {
    println!("release");
}

You can see the output of the release when you run it.
What does this mean?

You missed the ! after the #.

1 Like

This was overlooked.
It worked fine.
Thank you.