Compartilhar via


PREfast Warning 215 (Windows CE 5.0)

Send Feedback

215 - Cast between semantically different integer types.
Additional Information: Boolean to HRESULT.

**Note   **For this warning, the SCODE type is equivalent to HRESULT.

This warning indicates that a Boolean is being cast to an HRESULT.

This is likely to give undesirable results. For instance, the typical failure value for functions that return a Boolean (FALSE) is a success status when tested as an HRESULT.

This error frequently occurs when a Boolean is used as an argument to the SUCCEEDED or FAILED macro, which explicitly casts their arguments to an HRESULT.

In general, the SUCCEEDED or FAILED macros should only be applied to HRESULT.

Example

Defective Source

if (SUCCEEDED(SomeFunction())) {
    return 0;
} else {
    return -1;
}

Corrected Source

if (SomeFunction() == TRUE) {
    return 0;
} else {
    return -1;
}

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.