다음을 통해 공유


PREfast Warning 226 (Windows CE 5.0)

Send Feedback

226 - Implicit cast between semantically different integer types.
Additional Information: Assigning -1 to HRESULT.
Recommended Fix: Consider using E_FAIL instead.

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

This warning indicates that an HRESULT is being assigned or initialized with a value of an explicit, non-HRESULT -1; this is not a well-defined HRESULT. This warning is often caused by accidental confusion of integers and HRESULT values.

To indicate success, the symbolic constant S_OK should be used.

To indicate failure, some E_constant should be used.

Example

Defective Source

HRESULT hr = -1;

return hr;

Corrected Source

HRESULT hr = E_FAIL;

return hr;

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.