cargo-c icon indicating copy to clipboard operation
cargo-c copied to clipboard

Generate `nodiscard` for `#[must_use]` functions

Open kpcyrd opened this issue 6 months ago • 3 comments

Hello!

Since C23 there's the nodiscard attribute, I was wondering if marking an exported Rust function with #[must_use] should also set this attribute in the generated header file.

Thanks!

kpcyrd avatar Jun 09 '25 15:06 kpcyrd

that would be a great question for bindgen I guess.

lu-zero avatar Jun 09 '25 18:06 lu-zero

Good pointer, it seems there's https://github.com/rust-lang/rust-bindgen/pull/2081 but only for types

kpcyrd avatar Jun 09 '25 22:06 kpcyrd

I try to use the latest bindgen for the built-in support, in case another generator gets that first, you can still invoke it via build.rs and configure cargo-c to use the generated assets.

lu-zero avatar Jun 10 '25 06:06 lu-zero