|
|
Subscribe / Log in / New account

Unused parameters in C are worse than in Rust

Unused parameters in C are worse than in Rust

Posted Feb 11, 2025 15:30 UTC (Tue) by alx.manpages (subscriber, #145117)
In reply to: Unused parameters in C are worse than in Rust by farnz
Parent article: Maintainer opinions on Rust-for-Linux

> why is Rust's use of _ignored_cpu_mask "no documentation name either"?
> All names starting with an underscore are flagged as explicitly unused, not just the underscore on its own.

Ahh, sorry, I missed that. How about this?

#define _ [[maybe_unused]]

int
main(_ int argc, char *argv[])
{...}

The _() function already exists (for internationalization of strings), which is why I wouldn't shadow it with this macro, but if you don't use _(), when you could define the undescore to be [[maybe_unused]]. Or you could find another name that serves you.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds