更新 Visual Studio 2017,现在出现编译错误 C7510:"回调":使用依赖模板名称必须以 'template' 为前缀
Update visual studio 2017, now getting compile error C7510: 'Callback': use of dependent template name must be prefixed with 'template'
更新后,我尝试像往常一样编译我的项目(15.8.0(。 我将 showinclude 设置为 yes 以找出错误的来源,但这都是系统代码。 从 stdafx.cpp 开始,它会遍历所有包含和错误:
1>Note: including file: C:Program Files (x86)Windows Kits10Include10.0.17134.0sharedpshpack8.h 1>Note: including file: C:Program Files (x86)Windows Kits10Include10.0.17134.0sharedpoppack.h 1>Note: including file: C:Program Files (x86)Windows Kits10Include10.0.17134.0sharedpshpack8.h 1>Note: including file: C:Program Files (x86)Windows Kits10Include10.0.17134.0sharedpoppack.h 1>Note: including file: C:Program Files (x86)Windows Kits10Include10.0.17134.0winrtwrlevent.h 1>Note: including file: C:Program Files (x86)Windows Kits10Include10.0.17134.0winrteventtoken.h 1>Note: including file: C:Program Files (x86)Windows Kits10Include10.0.17134.0sharedpshpack8.h 1>c:program files (x86)windows kits10include10.0.17134.0winrtwrlevent.h(316): error C7510: 'Callback': use of dependent template name must be prefixed with 'template' 1>c:program files (x86)windows kits10include10.0.17134.0winrtwrlevent.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 行:返回委托助手::特征::回调(详细信息::转发(回调((;
to:返回委托助手::特征::模板回调(详细信息::转发(回调((;
第 324 行:返回委托助手::特征::回调(
返回委托助手::特征::模板回调(详细信息::转发(回调((;
由于修改 sdk 并不是真正的解决方案,因此 Peng Du 的解决方案是在配置窗口中选择不符合项。
我有遗留项目,我并排比较了项目设置,最后我通过设置成功构建了新项目:Configuration Properties
>C/C++
>Language
>Conformance mode = No
使用依赖模板名称时,必须使用template
关键字,例如:
foo.template bar<T>();
直到某个时候,MSVC 对使用typename
和template
消除歧义器并不严格,但在更新后,规则发生了变化。
问题出在Windows运行时库中,对Visual Studio的一些更改破坏了它。我在这台更新到 15.8.2 的笔记本电脑上遇到了同样的问题,我家里运行早期版本的机器不会这样做,因为完全相同的代码在我的另一台机器上编译,它一定是 VS 中的错误,或者 WRL/event 类中需要更改。
编辑:修复了上面的返回值,错误在SDK中,你不应该禁用/permissive-因为这可以防止Spectre和其他安全增强功能。
- 表示"accepting anything for this template argument" C++概念的通配符
- 传递给std::function template的template参数究竟代表什么
- 在template中使用std::variant的template函数
- 编译器如何在前缀和 postix 运算符之间进行区分?
- C++ template for QList
- 查找带有 Anaconda cmake 前缀的 boost-python3
- C++ - 为什么这里需要'template'关键字?
- 迭代器类的重载前缀增量运算符会引发分段错误
- 如何在友元函数中使用静态成员而不添加前缀 [类名]::
- 使用"std::enable_if_t" "function template has already been defined"
- 生成前缀位掩码
- C++模板错误:"invalid explicitly-specified argument for template parameter"
- 定义宏以将前缀 0x 添加到十六进制字符串文本
- CMake 错误 - 目标 foo INTERFACE_SOURCES属性包含在源目录中以前缀为前缀的路径
- C++ class template
- 如何在自定义对象的<<运算符中添加自定义前缀
- 在"template"和函数声明之间使用:template<typename trait> using tr = base_trait<trait> void fn(tr::t
- 为什么编译器说"candidate template ignored: couldn't infer template argument 'InputIterator'"?
- 为什么在这种情况下我需要 .template
- 更新 Visual Studio 2017,现在出现编译错误 C7510:"回调":使用依赖模板名称必须以 'template' 为前缀