warn_unusedvar

Controls the recognition of unreferenced variables.

Syntax
  #pragma warn_unusedvar on | off | reset
  
  
Remarks

If you enable this pragma, the compiler issues a warning message when it encounters a 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: Unused Local Variables Example shows an example.

Listing: Unused Local Variables Example

int error;

void func(void)

{

  int temp, errer; /* NOTE: errer is misspelled. */

  error = do_something(); /* WARNING: temp and errer 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: Suppressing Unused Variable Warnings.

Listing: Suppressing Unused Variable Warnings

void func(void)

{

  int i, temp, error;

  #pragma unused (i, temp) /* Do not warn that i and temp */

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

}