This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Silencing "unused parameter" warning


Any good suggestions for silencing the "unused parameter" warnings on a per-case basis? As opposed to turning them all off via compiler option, that is.

I'd like to avoid the warnings for placeholder routines and API-required parameters that happen not to be needed in some routines, while retaining the warning for truly unneeded parameters.

Stupid coding tricks I've used in the past with other tools include a cast to void (which just substitutes a "expression may have no effect" warning with C51, no net gain) and commenting out the parameter name (which just earns a "unnamed parameter" error from C51). If "unnamed parameter" were just a warning, I'd probably opt for that and squelch it globally, since it's not likely to occur accidentally, but C158 is an error and prevents compilation.

Any favorite tricks to share?

Parents
  • Would self-assignment consume too many machine cycles?
    I've a function wchich provides a delay based on the parameter in microseconds( I estimate the number of instructions necessary to be run based on the microcontroller speed, for a specified number of micro-seconds just by looping based on the input parameter).
    But rather than using the parameter(unsigned long)in my function, I directly extract it from the registers so that I save time and therefore get the exact delay. So, I end up with the warning unused parameter since the parameter isn't being used in the function.

    Any comments?

    -Sundeep

Reply
  • Would self-assignment consume too many machine cycles?
    I've a function wchich provides a delay based on the parameter in microseconds( I estimate the number of instructions necessary to be run based on the microcontroller speed, for a specified number of micro-seconds just by looping based on the input parameter).
    But rather than using the parameter(unsigned long)in my function, I directly extract it from the registers so that I save time and therefore get the exact delay. So, I end up with the warning unused parameter since the parameter isn't being used in the function.

    Any comments?

    -Sundeep

Children