If you enable the Unused Variables setting, the compiler generates a warning when it encounters a local variable you declare but do not use. This check helps you find variables that you either misspelled or did not use in your program. Listing 1 shows an 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 do not use, include the pragma unused, as in Listing 2.
void foo(void)
{
int i, temp, error;
#pragma unused (i, temp) /* Do not warn that i and temp */
error=do_something(); /* are not used */
}
The Unused Variables setting corresponds to the pragma warn_unusedvar, described at warn_unusedvar. To check this setting, use __option (warn_unusedvar).
See Checking Option Settings for information on how to use this directive.