【发布时间】:2020-11-05 15:22:33
【问题描述】:
使用包含 MIDL 3.0 简单类型 Char 的 idl 源:
namespace BrokenMIDL_Char
{
[default_interface]
runtimeclass MainPage : Windows.UI.Xaml.Controls.Page
{
MainPage();
Int32 MyProperty;
Char MyStationLetter_1;
//Char MyStationLetter_2;
//Char MyStationLetter_3;
}
}
及配套功能
wchar_t MyStationLetter_1()
{
throw hresult_not_implemented();
}
void MyStationLetter_1(wchar_t /*value*/)
{
throw hresult_not_implemented();
}
char16_t MyStationLetter_2()
{
throw hresult_not_implemented();
}
void MyStationLetter_2(char16_t /*value*/)
{
throw hresult_not_implemented();
}
char MyStationLetter_3()
{
throw hresult_not_implemented();
}
void MyStationLetter_3(char /*value*/)
{
throw hresult_not_implemented();
}
导致错误
T 必须是 WinRT 类型
我的理解是 MIDL 3.0 类型是 WinRT 类型的定义。
MIDL 编译器发出:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
template<typename TDeclaringType, typename TValue>
void SetValueTypeMember_MyStationLetter_1(
::winrt::Windows::Foundation::IInspectable const& instance,
::winrt::Windows::Foundation::IInspectable const& value)
{
instance.as<TDeclaringType>().MyStationLetter_1(::winrt::unbox_value<TValue>(value));
}
【问题讨论】:
-
在这种情况下
T是什么?显示的代码中没有T。 -
T 是 MIDL 编译器生成的文件代码(由其定义)的一部分。
-
你能显示那个代码吗?
-
MIDL 编译器发出 ``` 模板
void SetValueTypeMember_MyStationLetter_1( ::winrt::Windows::Foundation::IInspectable const& instance, ::winrt::Windows::Foundation ::IInspectable const& value) { instance.as ().MyStationLetter_1(::winrt::unbox_value (value)); } ``` -
这应该被编辑到你的问题中,而不是在 cmets 中发布。这次我已经为您完成了,下次请务必发布所有相关详细信息。话虽如此,我在这段代码中仍然没有看到任何
T,那么它到底在抱怨哪个T?假设TDeclaringType或TValue,它们在模板的实例化中实际设置为什么?
标签: c++-winrt