[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


Finding Unused Arguments

If the Unused Arguments option is on, the compiler generates a warning when it encounters an argument you declare but do not use. This check helps you find misspelled argument names and arguments you have written out of your program.


void foo(int temp,int errer); // ERROR: errer is misspelled
{
    error = do_something(); // WARNING: temp and error are unused.
}  

If you need to declare an argument that you don't use, there are two ways to avoid this warning. You can use the pragma unused, as in this example:


void foo(int temp, int error)
{
  #pragma unused (temp)
  /* Compiler won't warn that temp is not used */

    error=do_something();
}

You can also turn off the ANSI Strict option, and not give the unused argument a name. (See "Unnamed Arguments in Function Definitions.") For example:


void foo(int /* temp */, int error)
{
  /* Compiler won't warn that temp is not used, it's not named

    error=do_something(); */
}

The Unused Arguments option corresponds to the pragma warn_unusedarg, described at "warn_unusedarg." To check whether this option is on, use __option (warn_unusedarg). See "Checking Options" for information on how to use this directive.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 17, 2000