warn_resultnotused

Controls the issuing of warnings when function results are ignored.

Syntax

#pragma warn_resultnotused on | off | reset

Targets
All platforms.
Remarks

If you enable this pragma, the compiler issues a warning when it encounters a statement that calls a function without using its result. To prevent this, cast the statement with (void). Listing 10.45 provides an example.

Listing 10.45 Example of Function Calls with Unused Results

#pragma warn_resultnotused on

extern int bar();
void foo()
{
bar(); // WARNING: result of function call is not used
(void)bar(); // ‘void’ cast suppresses warning
}

For more information about this warning, see Ignored Function Results.

This pragma does not correspond to any panel setting. To check this setting, use __option (warn_resultnotused), described in Checking Settings. The default setting is off.