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. Unused Local Variables Example shows an example.

Listing 1. 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 Suppressing Unused Variable Warnings.

Listing 2. 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 */
}

By default, this pragma is off.

Related information
extended_errorcheck
maxerrorcount
message
showmessagenumber
show_error_filestack
suppress_warnings
sym
unused
warning
warning_errors
warn_any_ptr_int_conv
warn_emptydecl
warn_extracomma
warn_filenamecaps
warn_filenamecaps_system
warn_hiddenlocals
warn_illpragma
warn_illtokenpasting
warn_illunionmembers
warn_impl_f2i_conv
warn_impl_i2f_conv
warn_impl_s2u_conv
warn_implicitconv
warn_largeargs
warn_missingreturn
warn_no_side_effect
warn_padding
warn_pch_portability
warn_possunwant
warn_ptr_int_conv
warn_resultnotused
warn_undefmacro
warn_uninitializedvar
warn_unusedarg