{"id":2135,"date":"2020-12-14T17:47:30","date_gmt":"2020-12-14T15:47:30","guid":{"rendered":"https:\/\/alax.info\/blog\/?p=2135"},"modified":"2020-12-14T17:47:30","modified_gmt":"2020-12-14T15:47:30","slug":"windows-10-sdk-rtworkq-h-and-c-winrt-winrtimplements","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/2135","title":{"rendered":"Windows 10 SDK RTWorkQ.h and C++\/WinRT winrt::implements"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>interface DECLSPEC_UUID(\"ac6b7889-0740-4d51-8619-905994a55cc6\") DECLSPEC_NOVTABLE\r\n    IRtwqAsyncResult : public IUnknown\r\n{\r\n    STDMETHOD(GetState)( _Out_ IUnknown** ppunkState);\r\n    STDMETHOD(GetStatus)();\r\n    STDMETHOD(SetStatus)( HRESULT hrStatus);\r\n    STDMETHOD(GetObject)( _Out_ IUnknown ** ppObject);\r\n    STDMETHOD_(IUnknown *, GetStateNoAddRef)();\r\n};\r\n\r\ninterface DECLSPEC_UUID(\"a27003cf-2354-4f2a-8d6a-ab7cff15437e\") DECLSPEC_NOVTABLE\r\n    IRtwqAsyncCallback : public IUnknown\r\n{\r\n    STDMETHOD(GetParameters)( _Out_ DWORD* pdwFlags, _Out_ DWORD* pdwQueue );\r\n    STDMETHOD(Invoke)( _In_ IRtwqAsyncResult* pAsyncResult );\r\n};\r\n<\/code><\/pre>\n\n\n\n<p>Interface methods lack pure specifiers. This might be OK for some development but once you try to inherit your handler class from <code>public winrt::implements&lt;AsyncCallback, IRtwqAsyncCallback><\/code> you are in trouble!<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1>Foo.obj : error LNK2001: unresolved external symbol \"public: virtual long __cdecl IRtwqAsyncCallback::GetParameters(unsigned long *,unsigned long *)\" (?GetParameters@IRtwqAsyncCallback@@UEAAJPEAK0@Z)\n1>Foo.obj : error LNK2001: unresolved external symbol \"public: virtual long __cdecl IRtwqAsyncCallback::Invoke(struct IRtwqAsyncResult *)\" (?Invoke@IRtwqAsyncCallback@@UEAAJPEAUIRtwqAsyncResult@@@Z)<\/pre>\n\n\n\n<p>The problem exists in current Windows 10 SDK and since 10.0.18362.0 at the very least. <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>To work it around without touching SDK code, this project side addition would satisfy the compiler:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>IFACEMETHODIMP IRtwqAsyncCallback::GetParameters(&#91;&#91;maybe_unused]] DWORD* Flags, &#91;&#91;maybe_unused]] DWORD* Queue)\r\n{\r\n    std::terminate();\r\n    return E_NOTIMPL;\r\n}\r\nIFACEMETHODIMP IRtwqAsyncCallback::Invoke(&#91;&#91;maybe_unused]] IRtwqAsyncResult* AsyncResult)\r\n{\r\n    std::terminate();\r\n    return E_NOTIMPL;\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Interface methods lack pure specifiers. This might be OK for some development but once you try to inherit your handler class from public winrt::implements&lt;AsyncCallback, IRtwqAsyncCallback> you are in trouble! 1>Foo.obj : error LNK2001: unresolved external symbol &#8220;public: virtual long __cdecl IRtwqAsyncCallback::GetParameters(unsigned long *,unsigned long *)&#8221; (?GetParameters@IRtwqAsyncCallback@@UEAAJPEAK0@Z) 1>Foo.obj : error LNK2001: unresolved external symbol &#8220;public: virtual&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/2135\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[38,588],"class_list":["post-2135","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-c","tag-c-winrt"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/2135","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=2135"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/2135\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=2135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=2135"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=2135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}