I’m looking for something equivalent to the following macro:
#define FAILED_CHECK(hr) if(FAILED(hr)) return hr;
is there any implementation inside the ATL library that does as shown above?
thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For whatever reason, ATL have not been providing an extremely useful macro like requested. Starting a few releases of Visual Studio back, ATL introduced similar macros:
but once again, there was no immediate match. You have to define your own. Or alternatively, switch to throwing exceptions on error conditions. ATL provides useful macros for this:
ATLENSURE_THROW,ATLENSURE_SUCCEEDEDand friends.In particular, you can throw exception on failure
HRESULTusingATLENSURE_SUCCEEDEDand then catch exception, esp. before return from COM interface call, converting it back to HRESULT: