-
Notifications
You must be signed in to change notification settings - Fork 38
Unused function parameters - declare (how) or just disable warning? #17
Comments
Personally I prefer the unused macro, as it makes things explicit. |
I think the cleanest solution is to use of the following:
The following is bad, since not portable
|
I did not know about the |
+1 for Simons first solution. Am 30.04.2014 um 12:10 schrieb "Simon Lynen" <[email protected]mailto:[email protected]>: I think the cleanest solution is to use of the following: void Process(int parameterA, bool /parameterB/) { void Process(int parameterA, bool parameterB) { The following is bad, since not portable void Process(int parameterA, bool parameterB attribute((unused))) { — |
I like Simon's first solution as well. I guess we basically agreed on that. |
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. |
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 :
Contra: bad when you want to start using it, maybe irritating when reading
Pro: no macro needed (to create compiler independent code)
Contra: need macro and that macro needs a place (header file ...)
Pro: can be nice to read and self documenting
Contra: killing useful warning
Pro: simple
What do you think / how do you currently handle that?
The text was updated successfully, but these errors were encountered: