How to detect at compile time what backend im using #7835
Replies: 1 comment
-
|
It seems like you want to do conditional compilation based on another crate's features. This is not possible in Rust. The best you can do is create the features in your crate and forward them to eframe, then you'll know for sure that the feature you are using is enabled, because you enabled it. This is what the demo app does. egui/crates/egui_demo_app/Cargo.toml Lines 39 to 40 in a9e9252 egui/crates/egui_demo_app/src/backend_panel.rs Lines 201 to 265 in a9e9252 The drawback is that if something else in the project depends on eframe and enables some backends without enabling them in your crate, your crate won't be able to know that they are enabled and won't use the code. I don't think there is a way around it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm writing a little screen to show information on what backend the program is compiled for, but I want to be able to move between glow or wgpu and detect what backend I'm using so I can enable and disable code based on that
example for wgpu I want this code to be disabled because if I'm using glow as those methods do not exist in glow
Beta Was this translation helpful? Give feedback.
All reactions