lobaro / FreeRTOS-rust

Rust crate for FreeRTOS
MIT License
326 stars 55 forks source link

Allow not to use `vTaskDelete()` #51

Closed JalonWong closed 1 year ago

JalonWong commented 1 year ago

Currently, if INCLUDE_vTaskDelete is set to 0, the compilation will fail.

rust-lld: error: undefined symbol: freertos_rs_delete_task
>>> referenced by task.rs:167 (src\task.rs:167)
schteve commented 1 year ago

I don't like the approach of modifying the internals of the function - if the user was trying to not include it, but the function is still available from the Rust side, it could result in some weird behavior for them. I'd much rather gate it with a feature flag on the Rust side since that's the approach we already took elsewhere.

Right now it looks like freertos_rs_delete_task() is only used when spawning a task so maybe that's easy to do. We have had issues in the past where the linker still complains, and I'm not sure why - would be nice to learn more.

JalonWong commented 1 year ago

Add a feature in Cargo.toml, is this appropriate?

schteve commented 1 year ago

Yes you've got the idea, I would prefer the logic to not be negative here (cfg(not(not_delete_task)) -> cfg(delete_task)). This also means the feature is needed in the default list too.

JalonWong commented 1 year ago

Yes you've got the idea, I would prefer the logic to not be negative here (cfg(not(not_delete_task)) -> cfg(delete_task)). This also means the feature is needed in the default list too.

Modified

schteve commented 1 year ago

Thanks!