C++/WinRT,Windows SDK 17134的一部分与Visual Studio 15.8 Preview 3
C++/WinRT, part of Windows SDK 17134 is not compatible with Visual Studio 15.8 Preview 3
正在尝试编译以下代码:
#include <winrt/base.h>
int main() {}
使用以下编译器选项:
/permissive- /std:c++latest
最近发布的 Visual Studio 15.8 预览版 3.0 会导致以下编译错误:
1>------ Build started: Project: test1, Configuration: Debug x64 ------
1>Source.cpp
1>c:program files (x86)windows kits10include10.0.17134.0cppwinrtwinrtbase.h(2185): error C3861: 'from_abi': identifier not found
1>c:program files (x86)windows kits10include10.0.17134.0cppwinrtwinrtbase.h(2185): note: This diagnostic occurred in the compiler generated function 'conditional<_Test,T,_Ty2>::type winrt::impl::as(From *)'
1> with
1> [
1> _Ty2=winrt::com_ptr<T>
1> ]
1>c:program files (x86)windows kits10include10.0.17134.0cppwinrtwinrtbase.h(2209): error C3861: 'from_abi': identifier not found
1>c:program files (x86)windows kits10include10.0.17134.0cppwinrtwinrtbase.h(2209): note: This diagnostic occurred in the compiler generated function 'conditional<_Test,T,_Ty2>::type winrt::impl::try_as(From *) noexcept'
1> with
1> [
1> _Ty2=winrt::com_ptr<T>
1> ]
1>c:program files (x86)windows kits10include10.0.17134.0cppwinrtwinrtbase.h(3850): error C3861: 'from_abi': identifier not found
1>c:program files (x86)windows kits10include10.0.17134.0cppwinrtwinrtbase.h(3873): note: see reference to class template instantiation 'winrt::weak_ref<T>' being compiled
1>c:program files (x86)windows kits10include10.0.17134.0cppwinrtwinrtbase.h(2984): note: see reference to class template instantiation 'winrt::com_ptr<ILanguageExceptionErrorInfo2>' being compiled
1>c:program files (x86)windows kits10include10.0.17134.0cppwinrtwinrtbase.h(3054): note: see reference to class template instantiation 'winrt::com_ptr<IRestrictedErrorInfo>' being compiled
1>c:program files (x86)microsoft visual studiopreviewprofessionalvctoolsmsvc14.15.26608includetype_traits(616): note: see reference to class template instantiation 'std::basic_string_view<wchar_t,std::char_traits<wchar_t>>' being compiled
1>c:program files (x86)microsoft visual studiopreviewprofessionalvctoolsmsvc14.15.26608includexstring(2124): note: see reference to class template instantiation 'std::is_convertible<const _StringViewIsh &,std::basic_string_view<wchar_t,std::char_traits<wchar_t>>>' being compiled
1> with
1> [
1> _StringViewIsh=const wchar_t *
1> ]
1>c:program files (x86)microsoft visual studiopreviewprofessionalvctoolsmsvc14.15.26608includexstring(2122): note: see reference to variable template 'const bool conjunction_v<std::is_convertible<wchar_t const * const &,std::basic_string_view<wchar_t,std::char_traits<wchar_t> > >,std::negation<std::is_convertible<wchar_t const * const &,wchar_t const *> > >' being compiled
1>c:program files (x86)microsoft visual studiopreviewprofessionalvctoolsmsvc14.15.26608includexstring(2281): note: see reference to alias template instantiation '_Is_string_view_ish<const wchar_t*>' being compiled
1>c:program files (x86)windows kits10include10.0.17134.0cppwinrtwinrtbase.h(6308): error C3861: 'to_abi': identifier not found
1>Done building project "test1.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
有什么解决办法吗?
这是一个已知问题,将在未来的 Windows 10 SDK 更新中解决。
您可以通过完全关闭一致性模式 (/permissive-
( 来解决此问题,或者通过添加到"附加选项"/Zc:twoPhase-
来禁用两阶段名称查找来保持打开状态。
对于 C++/WinRT,应将
/std:c++latest
/std:c++17
而不是与 VS 2017 一起使用,以启用 C++17,而无需选择将来的草稿更改。
更新:此问题已使用 Windows 10 2018 年 10 月更新 SDK (17763( 解决。
我做了一个小补丁来解决这个问题。它添加了几个前向声明,因此可以通过两阶段查找和缺少template
关键字找到必要的名称。
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>();
相关文章:
- Visual Studio 2015:Extern "C" 和 "export" 关键字
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 试图在visual studio上用C++创建一个桌面应用程序
- 如何在MS Visual Studio 2019中运行QT UI
- 如何使用Visual Studio 2017在C++中为参数化对象数组使用唯一指针
- Visual Studio Code - C++ Debugger 無法啟動
- Visual Studio 2019:插入多个C++风格的单行注释
- Visual Studio Code "undefined reference to `WinMain@16'"
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- Visual Studio中的函数声明和函数定义问题
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- Visual Studio mkl_link_tool.exe链接错误
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 不同的Visual Studio版本中缺少.dll
- 用Visual Studio在C++中嵌入Julia
- Visual Studio 2017循环自动向量化问题
- 有没有办法在远程设备上打开和编辑visual Studio 2017解决方案
- 尝试使用继承和模板实现CRTP.Visual Studio正在生成编译器错误
- Visual Studio在尝试读取resource.txt文件时崩溃
- Visual Studio 2017 不允许我创建 C++ 专用模板