headers: Implement _set_com_error_handler and _com_raise_error in comdef.h These could also possibly be made non-inline if we'd be providing the comsupp library. However, that could break existing code that calls _com_issue_error (implicitly via _com_ptr_t in comip.h) and don't currently explicitly link in any comsupp library (which doesn't exist currently either). In the corresponding MSVC setups, the comsupp library is linked in automatically via '#pragma comment(lib, "comsupp.lib")' in the comdef.h header. Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-headers/include/comdef.h b/mingw-w64-headers/include/comdef.h index 9d4e97f..cb785f8 100644 --- a/mingw-w64-headers/include/comdef.h +++ b/mingw-w64-headers/include/comdef.h
@@ -29,8 +29,6 @@ #ifdef __cplusplus class _com_error; -void WINAPI _com_raise_error(HRESULT hr,IErrorInfo *perrinfo = 0); -void WINAPI _set_com_error_handler(void (WINAPI *pHandler)(HRESULT hr,IErrorInfo *perrinfo)); void WINAPI _com_issue_errorex(HRESULT,IUnknown*,REFIID); HRESULT WINAPI _com_dispatch_propget(IDispatch*,DISPID,VARTYPE,void*); HRESULT __cdecl _com_dispatch_propput(IDispatch*,DISPID,VARTYPE,...); @@ -165,15 +163,25 @@ if(m_perrinfo!=NULL) m_perrinfo->AddRef(); } -inline void _com_issue_error(HRESULT hr) { +inline void WINAPI _com_raise_error(HRESULT hr, IErrorInfo *perrinfo = 0) { #if __EXCEPTIONS - throw _com_error(hr); + throw _com_error(hr, perrinfo); #else /* This is designed to use exceptions. If exceptions are disabled, there is not much we can do here. */ __debugbreak(); #endif } +__MINGW_SELECTANY void (WINAPI *__mingw_com_error_handler)(HRESULT hr,IErrorInfo *perrinfo) = _com_raise_error; + +inline void WINAPI _set_com_error_handler(void (WINAPI *pHandler)(HRESULT hr,IErrorInfo *perrinfo)) { + __mingw_com_error_handler = pHandler; +} + +inline void WINAPI _com_issue_error(HRESULT hr) { + __mingw_com_error_handler(hr, NULL); +} + typedef int __missing_type__;