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


Catching Redundant Statements

When the warn_no_side_effect pragma is on, the compiler will issue a warning when it encounters a statement that produces no side effect. To prevent a statement with no side effects from signalling this warning, cast the statement with (void). See Listing 6.1 for an example.

Example of pragma warn_no_side_effect:
#pragma warn_no_side_effect on
void foo(int a,int b)
{
   a+b; // warning: expression has no side effect
   (void)(a+b); // void cast suppresses warning
}


[ 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