Skip to content

Comment on Way too many ways to wait on a child process with a timeout

Comments

What is the meaning of this code ?

  void on_sigchld(int sig) { (void)sig; }

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*/) {}

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:

  -Wall -Wextra -Wno-unused-parameter
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.