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


Finding Unused Variables

If the Unused Variables option is on, the compiler generates a warning when it encounters a variable that you declare but do not use. This check helps you find misspelled variable names and variables you have written out of your program. For example:


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

If you want to use this warning, but need to declare a variable that you don't use, use the pragma unused, as in this example:


void foo(void)
{
    int i, temp, error;

  #pragma unused (i, temp) /* Compiler won't warn that i and temp

    error=do_something();      /* are not used */

}

The Unused Variables option corresponds to the pragma warn_unusedvar, described at "warn_unusedvar." To check whether this option is on, use __option (warn_unusedvar). 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