Closed HannesSommer closed 9 years ago
Personally I prefer the unused macro, as it makes things explicit.
I think the cleanest solution is to use of the following:
void Process(int parameterA, bool /*parameterB*/) {
}
void Process(int parameterA, bool parameterB) {
static_cast<void>(parameterB);
}
The following is bad, since not portable
void Process(int parameterA, bool parameterB __attribute__((__unused__))) {
}
I did not know about the static_cast
trick, not a bad solution but a bit geeky. Maybe have the name in comments is the simplest solution after all.
+1 for Simons first solution.
Am 30.04.2014 um 12:10 schrieb "Simon Lynen" notifications@github.com<mailto:notifications@github.com>:
I think the cleanest solution is to use of the following:
void Process(int parameterA, bool /parameterB/) { }
void Process(int parameterA, bool parameterB) {
static_cast
The following is bad, since not portable
void Process(int parameterA, bool parameterB attribute((unused))) { }
— Reply to this email directly or view it on GitHubhttps://github.com/ethz-asl/programming_guidelines/issues/17#issuecomment-41780461.
I like Simon's first solution as well.
I guess we basically agreed on that. We should include it in the guideline. Any objections?
Yes, please include it in the guidelines!
And anyone feel free to update current code!
I've just pushed a small perl script (to this rep) to do convert existing code based on the compiler warnings (e.g. Jenkin's raw output)
It is NOT perfect. So check the result after use (e.g. git diff).
Reopening to not forget the entry in the guidelines.
@HannesSommer , can you update the programming guidelines?
Yes, I will do that. The big problem with the guidelines is that it needs cleaning up and the github wiki language/interface is just a bit too limited to support that well. This is blocking me to work on it - maybe I manage to find a good way to improve the situation this time...
Feel free to use Latex if that helps. For now, just add this to the list and close the issue.
Added the essence as paragraph 68b to the style guide. https://github.com/ethz-asl/programming_guidelines/wiki/Cpp-Coding-Style-Guidelines#68b-unused-function-parameters-should-have-a-name-comment-instead-of-a-name
I currently wander what to do with unused parameters. Especially when it comes to overriding they are clearly unavoidable. But the compiler warning seem quit e useful (enabled implicitly with -Wextra)
With gcc there seem to be three options :
What do you think / how do you currently handle that?