다음을 통해 공유


PREfast Warning 230 (Windows CE 5.0)

Send Feedback

230 - Implicit cast between semantically different integer types.
Additional Information: Using HRESULT in a Boolean context.
  • Note   For this warning, the SCODE type is equivalent to HRESULT.

This warning indicates that a bare HRESULT is being used in a context (such as the test of an if statement) where a Boolean result is expected.

This is likely to give undesirable results. For instance, the typical success value for HRESULT (S_OK) is FALSE when tested as a Boolean.

In most situations, the SUCCEEDED or FAILED macro should be used to test the value of the HRESULT.

Example

Defective Source

HRESULT hr;

hr = GetResult();

if (hr) {
    return false;
} else {
    return true;
}

Corrected Source

HRESULT hr;

hr = GetResult();

if (FAILED(hr)) {
    return false;
} else {
    return true;
}

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.