Skip to content

Can't implement WinRT interfaces in a module partition #1199

@jaigak

Description

@jaigak

Having exported classes in a module partition that implements WinRT interfaces by deriving from the winrt::implements class template doesn't seem to work and gives this error:

1>S:\ConsoleApplication1\ConsoleApplication1\x64\Debug\Generated Files\winrt\base.h(857,21): error C2676: binary '==': 'const winrt::guid' does not define this operator or a conversion to a type acceptable to the predefined operator
1>S:\ConsoleApplication1\ConsoleApplication1\x64\Debug\Generated Files\winrt\base.h(7206,1): message : see reference to function template instantiation 'bool winrt::is_guid_of<winrt::impl::IWeakReference>(const winrt::guid &) noexcept' being compiled
1>S:\ConsoleApplication1\ConsoleApplication1\x64\Debug\Generated Files\winrt\base.h(7205,1): message : while compiling class template member function 'int32_t winrt::impl::weak_ref<true,true>::QueryInterface(const winrt::guid &,void **) noexcept'
1>S:\ConsoleApplication1\ConsoleApplication1\x64\Debug\Generated Files\winrt\base.h(7613,1): message : see reference to class template instantiation 'winrt::impl::weak_ref<true,true>' being compiled
1>S:\ConsoleApplication1\ConsoleApplication1\x64\Debug\Generated Files\winrt\base.h(7604,1): message : while compiling class template member function 'uint32_t winrt::impl::root_implements<D,winrt::Windows::Foundation::IStringable>::subtract_final_reference(void) noexcept'
1>        with
1>        [
1>            D=Stringable
1>        ]
1>S:\ConsoleApplication1\ConsoleApplication1\x64\Debug\Generated Files\winrt\base.h(7446,37): message : see reference to function template instantiation 'uint32_t winrt::impl::root_implements<D,winrt::Windows::Foundation::IStringable>::subtract_final_reference(void) noexcept' being compiled
1>        with
1>        [
1>            D=Stringable
1>        ]
1>S:\ConsoleApplication1\ConsoleApplication1\x64\Debug\Generated Files\winrt\base.h(7979,1): message : see reference to class template instantiation 'winrt::impl::root_implements<D,winrt::Windows::Foundation::IStringable>' being compiled
1>        with
1>        [
1>            D=Stringable
1>        ]
1>S:\ConsoleApplication1\ConsoleApplication1\Module.ixx(3,1): message : see reference to class template instantiation 'winrt::implements<Stringable,winrt::Windows::Foundation::IStringable>' being compiled
1>S:\ConsoleApplication1\ConsoleApplication1\x64\Debug\Generated Files\winrt\base.h(857,21): error C2088: '==': illegal for struct

Source

Remember to disable precompiled headers first.

Module.ixx

export module Module;

export import :WinRT;

Module-WinRT.ixx

module;

#include <winrt/Windows.Foundation.h>

export module Module:WinRT;

using namespace winrt;

export struct Stringable : implements<Stringable, Windows::Foundation::IStringable>
{
	hstring ToString()
	{
		return L"Hello for C++ modules!";
	}
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions