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ö <mar...@martin.st>
---
 mingw-w64-headers/include/comdef.h | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-headers/include/comdef.h 
b/mingw-w64-headers/include/comdef.h
index 9d4e97ffc..f29f3f8fa 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 @@ inline void _com_error::Ctor(const _com_error &that) 
throw() {
   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 *__error_handler)(HRESULT hr,IErrorInfo 
*perrinfo) = _com_raise_error;
+
+inline void WINAPI _set_com_error_handler(void (WINAPI *pHandler)(HRESULT 
hr,IErrorInfo *perrinfo)) {
+  __error_handler = pHandler;
+}
+
+inline void WINAPI _com_issue_error(HRESULT hr) {
+  __error_handler(hr, NULL);
+}
+
 
 typedef int __missing_type__;
 
-- 
2.25.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to