← Back to context Comment by JackSlateur 1 month ago What is the meaning of this code ? void on_sigchld(int sig) { (void)sig; } 4 comments JackSlateur Reply naruhodo 1 month ago If it's C code, that is the way to suppress a compiler warning about sig being unused. In C++ you can omit (or comment-out) the parameter name, e.g.: // C++ void on_sigchld(int /*sig*/) {} JackSlateur 1 month ago Thank youSo this would be a way which predates' C23's maybe_unused attribute¹Nice trick[1] https://en.cppreference.com/w/c/language/attributes/maybe_un... naruhodo 25 days ago C23 includes support for just omitting the parameter name, as with C++. kevin_thibedeau 1 month ago That is K&R C syntax, supported up to C18. The solution to tools emitting unwanted diagnostics is not to appease them with pointless cruft but to shut off the diagnostic: -Wall -Wextra -Wno-unused-parameter
naruhodo 1 month ago If it's C code, that is the way to suppress a compiler warning about sig being unused. In C++ you can omit (or comment-out) the parameter name, e.g.: // C++ void on_sigchld(int /*sig*/) {} JackSlateur 1 month ago Thank youSo this would be a way which predates' C23's maybe_unused attribute¹Nice trick[1] https://en.cppreference.com/w/c/language/attributes/maybe_un... naruhodo 25 days ago C23 includes support for just omitting the parameter name, as with C++. kevin_thibedeau 1 month ago That is K&R C syntax, supported up to C18. The solution to tools emitting unwanted diagnostics is not to appease them with pointless cruft but to shut off the diagnostic: -Wall -Wextra -Wno-unused-parameter
JackSlateur 1 month ago Thank youSo this would be a way which predates' C23's maybe_unused attribute¹Nice trick[1] https://en.cppreference.com/w/c/language/attributes/maybe_un... naruhodo 25 days ago C23 includes support for just omitting the parameter name, as with C++.
kevin_thibedeau 1 month ago That is K&R C syntax, supported up to C18. The solution to tools emitting unwanted diagnostics is not to appease them with pointless cruft but to shut off the diagnostic: -Wall -Wextra -Wno-unused-parameter
If it's C code, that is the way to suppress a compiler warning about sig being unused. In C++ you can omit (or comment-out) the parameter name, e.g.:
Thank you
So this would be a way which predates' C23's maybe_unused attribute¹
Nice trick
[1] https://en.cppreference.com/w/c/language/attributes/maybe_un...
C23 includes support for just omitting the parameter name, as with C++.
That is K&R C syntax, supported up to C18. The solution to tools emitting unwanted diagnostics is not to appease them with pointless cruft but to shut off the diagnostic: