Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Table of "safe" methods to suppress "unused parameter" warnings?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="David Brown, post: 5152232"] I disagree (at least a bit) here - I don't see any reason to have unnamed parameters in C. If the parameter is completely useless, then it should be removed entirely - if not, then the name is part of the documentation for the function's interface. Just because it is not used in this particular version of the implementation of the function, does not mean it should not be named. And the solution to the original problem is nothing more dramatic than "(void) x;", which is neither hard to write nor hard to understand. In C++, I can think of a situation where unnamed parameters make sense - you might want a function that requires you to have an object of a particular class but does not care about the contents. This can be used to give compile-time checking of constraints. For example, if your system has a global interrupt lock, then you might use a class "InterruptDisabler" whose constructor preserves the old interrupt state and disables interrupts, and whose destructor restores the state. A function that expects interrupts to be disabled could take an unnamed parameter of type "const InterruptDisabler&". [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Table of "safe" methods to suppress "unused parameter" warnings?
Top