首页 > 解决方案 > 更新 Visual Studio 2017,现在出现编译错误 C7510:“回调”:使用依赖模板名称必须以“模板”为前缀

问题描述

在更新(15.8.0)之后,我尝试像往常一样编译我的项目。我将 showincludes 设置为 yes 以找出错误的来源,但它都是系统代码。从 stdafx.cpp 开始,它会遍历所有包含和错误:

 1>Note: including file:     C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\pshpack8.h
 1>Note: including file:     C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\poppack.h
 1>Note: including file:    C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\pshpack8.h
 1>Note: including file:    C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\poppack.h
 1>Note: including file:   C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt\wrl\event.h
 1>Note: including file:    C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\winrt\eventtoken.h
 1>Note: including file:    C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\shared\pshpack8.h
 1>c:\program files (x86)\windows kits\10\include\10.0.17134.0\winrt\wrl\event.h(316): error C7510: 'Callback': use of dependent template name must be prefixed with 'template'
 1>c:\program files (x86)\windows kits\10\include\10.0.17134.0\winrt\wrl\event.h(324): error C7510: 'Callback': use of dependent template name must be prefixed with 'template'

有没有人见过这个?我在谷歌上下搜索以找到无济于事的答案。缺少修改windows sdk,不知道该怎么做。

编辑:在我安装的 Windows SDK 中,错误出现在文件中 -

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

更改第 316 行:返回 DelegateHelper::Traits::Callback(Details::Forward(callback));

to: return DelegateHelper::Traits::template Callback(Details::Forward(callback));

和第 324 行:返回 DelegateHelper::Traits::Callback(

返回 DelegateHelper::Traits::template Callback(Details::Forward(callback));

由于修改 sdk 并不是真正的解决方案,Peng Du 在配置窗口中选择 nonconformance 的解决方案是可行的方法。

标签: c++windowsvisual-studiowrl

解决方案


我有遗留项目,我并排比较了项目设置,最后我通过设置成功构建了新项目:Configuration Properties>>>C/C++LanguageConformance mode = No


推荐阅读