Compartir a través de


PREfast Warning 219 (Windows CE 5.0)

Send Feedback

219 - Implicit cast between semantically different integer types.
Additional Information: Comparing HRESULT to 1 or TRUE. 
Recommended Fix: Consider using SUCCEEDED or FAILED macro instead.Note   For this warning, the SCODE type is equivalent to HRESULT.

This warning indicates that an HRESULT is being compared against an explicit, non-HRESULT value of one (1). This is likely to give undesirable results.

The typical success value for HRESULT, S_OK, is not equal to TRUE.

In most cases, this warning is caused by the code mistakenly treating an HRESULT as a Boolean. It is generally best to use the SUCCEEDED or FAILED macros to test the value of an HRESULT.

Example

Defective Source

if (SomeFunction() == TRUE) {
    return S_OK;
}

return E_FAIL;

Corrected Source

if (SUCCEEDED(SomeFunction())) {
    return S_OK;
}

return E_FAIL;

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.