0

在 C++/WinRT 中,我手工编写了一些这样的类(不使用 idls):

class GenericController: public winrt::Windows::Foundation::IInspectable {
...
}

class BackgroundController1: public winrt::implements<BackgroundController1, GenericController> {
...
}

我创建这样的对象:

auto controller = winrt::make<BackgroundController1>();

对于派生自 winrt:implements<BackgroundControllerX, GenericController> 的每个类,我都收到以下错误:

Error   C3668   'winrt::impl::produce_base<D,I,void>::QueryInterface': method with override specifier 'override' did not override any base class methods    C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt\winrt\base.h   8016    
Error   C3668   'winrt::impl::produce_base<D,I,void>::AddRef': method with override specifier 'override' did not override any base class methods    C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt\winrt\base.h   8021    
Error   C3668   'winrt::impl::produce_base<D,I,void>::Release': method with override specifier 'override' did not override any base class methods   C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt\winrt\base.h   8026    
Error   C3668   'winrt::impl::produce_base<D,I,void>::GetIids': method with override specifier 'override' did not override any base class methods   C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt\winrt\base.h   8031    
Error   C3668   'winrt::impl::produce_base<D,I,void>::GetRuntimeClassName': method with override specifier 'override' did not override any base class methods   C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt\winrt\base.h   8036    
Error   C3609   'winrt::impl::produce_base<D,I,void>::GetTrustLevel': a 'final' function must be virtual    C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt\winrt\base.h   8041    
Error   C2440   'initializing': cannot convert from 'initializer list' to 'GenericController' (compiling source file C:\Users\...\BackgroundController1.cpp)    C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt\winrt\base.h   8814    

这是输出日志:

error C3668: 'winrt::impl::produce_base<D,I,void>::QueryInterface': method with override specifier 'override' did not override any base class methods
1>        with
1>        [
1>            D=`anonymous-namespace'::BackgroundController1,
1>            I=GenericController
1>        ]
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(7737): note: see reference to class template instantiation 'winrt::impl::produce_base<D,I,void>' being compiled
1>        with
1>        [
1>            D=`anonymous-namespace'::BackgroundController1,
1>            I=GenericController
1>        ]
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(8005): note: see reference to class template instantiation 'winrt::impl::produce<D,I>' being compiled
1>        with
1>        [
1>            D=`anonymous-namespace'::BackgroundController1,
1>            I=GenericController
1>        ]
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(7685): note: see reference to class template instantiation 'winrt::impl::producer<D,GenericController,void>' being compiled
1>        with
1>        [
1>            D=`anonymous-namespace'::BackgroundController1
1>        ]
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(8829): note: see reference to class template instantiation 'winrt::impl::producers_base<D,std::tuple<GenericController>>' being compiled
1>        with
1>        [
1>            D=`anonymous-namespace'::BackgroundController1
1>        ]
1>note: see reference to class template instantiation 'winrt::implements<`anonymous-namespace'::BackgroundController1,GenericController>' being compiled
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(10615): note: see reference to class template instantiation 'winrt::com_ptr<winrt::impl::IContextCallback>' being compiled
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(10349): note: see reference to class template instantiation 'winrt::com_ptr<winrt::impl::IServerSecurity>' being compiled
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(10308): note: see reference to class template instantiation 'std::chrono::time_point<winrt::clock,winrt::Windows::Foundation::TimeSpan>' being compiled 
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(6462): note: see reference to class template instantiation 'winrt::com_ptr<winrt::impl::IMarshal>' being compiled 
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\cppwinrt\winrt/base.h(210): note: see reference to class template instantiation 'std::array<uint8_t,8>' being compiled 

看起来类的编写方式和对象的创建方式可能有问题。但我无法弄清楚是什么或为什么。

4

0 回答 0