C++/WinRT, part of Windows SDK 17134 is not compatible with Visual Studio 15.8 Preview 3

[亡魂溺海] 提交于 2019-11-29 06:54:15

This is a known issue which will be addressed in a future Windows 10 SDK update.

You can work around it by either turning off Conformance Mode entirely (/permissive-), -or- keep it on by adding to the Additional Options /Zc:twoPhase- to disable two-phase name lookup.

You should use /std:c++17 and not /std:c++latest with VS 2017 for C++/WinRT to enable C++17 without opting in to future draft changes.

UPDATE: This issue is resolved using the Windows 10 October 2018 Update SDK (17763).

I made a little patch to fix this problem. It adds a couple of forward declarations so necessary names could be found with two-phase lookup and a missing template keyword.

C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\cppwinrt\winrt\base.h

2171a2172,2189
>     template <typename D, typename I, typename Enable = void>
>     struct producer;
> }
> 
> WINRT_EXPORT namespace winrt
> {
>     template <typename D, typename I>
>     D* from_abi(I const& from) noexcept;
> 
>   template <typename I, typename D, std::enable_if_t<std::is_base_of_v<Windows::Foundation::IUnknown, I>>* = nullptr>
>     impl::abi_t<I>* to_abi(impl::producer<D, I> const* from) noexcept;
> 
>     template <typename I, typename D, std::enable_if_t<std::is_base_of_v< ::IUnknown, I>>* = nullptr>
>     impl::abi_t<I>* to_abi(impl::producer<D, I> const* from) noexcept;
> }
> 
> namespace winrt::impl
> {
6244c6262
<     template <typename D, typename I, typename Enable = void>
---
>     template <typename D, typename I, typename Enable>
6353c6371
<     template <typename I, typename D, std::enable_if_t<std::is_base_of_v<Windows::Foundation::IUnknown, I>>* = nullptr>
---
>     template <typename I, typename D, std::enable_if_t<std::is_base_of_v<Windows::Foundation::IUnknown, I>>*>
6359c6377
<     template <typename I, typename D, std::enable_if_t<std::is_base_of_v< ::IUnknown, I>>* = nullptr>
---
>     template <typename I, typename D, std::enable_if_t<std::is_base_of_v< ::IUnknown, I>>*>
7189c7207
<             return root_implements_type::get_weak<D>();
---
>             return root_implements_type::template get_weak<D>();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!