更新visual studio 2017,现在得到编译错误C7510:'回调':使用依赖模板名称必须以'template'为前缀

问题描述 投票:2回答:3

我在更新后尝试像往常一样编译我的项目(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的解决方案是可行的。

c++ windows visual-studio wrl
3个回答
8
投票

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


5
投票

当您使用依赖模板名称时,您可以使用have to use a template keyword,例如:

foo.template bar<T>();

直到MSVC对使用typenametemplate消歧器并不严格,但更新后规则已经改变。


1
投票

问题出在Windows运行时库中,对Visual Studio的一些更改打破了它。我在这台更新到15.8.2的笔记本电脑上遇到了同样的问题,我家运行早期版本的机器没有这样做,因为完全相同的代码编译在我的另一台机器上,它必须是VS中的一个bug,或者WRL /事件类所需的更改。

编辑:修复上述工作的返回值,错误在SDK中,你不应该禁用/许可 - 因为这可以防止幽灵和其他安全增强。

© www.soinside.com 2019 - 2024. All rights reserved.