Update visual studio 2017, now getting compile error C7510: 'Callback': use of dependent template name must be prefixed with 'template'
Asked Answered
A

3

5

I tried compiling my project as usual after the update (15.8.0). I set showincludes to yes to figure out where the error originates, but it's all system code. Starting with stdafx.cpp, it goes through all the includes and errors out:

 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'

Has anyone seen this before? I googled up and down to find an answer to no avail. Short of modifying the windows sdk, not sure what to do.

Edit: In my installed windows SDK, the error was in the file-

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

Changed line 316: return DelegateHelper::Traits::Callback(Details::Forward(callback));

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

and line 324: return DelegateHelper::Traits::Callback(

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

Since modifying an sdk is not really a solution, Peng Du's solution by selecting non conformance in the configuration window is the way to go.

Autorotation answered 15/8, 2018 at 18:36 Comment(5)
"Starting with stdafx" - maybe get rid of that one already, for a build with fewer surprises.Delvecchio
Going down the list. Checking them off as I go.Autorotation
It looks like the error is coming from a subproject, DirectXTK12 after the update. This might be an error in the tool kit source code rather than the sdk.Autorotation
@JesperJuhl: That won't really help. It's not major magic. Besides, the problem is in an SDK header, and if you need that, you need it. How you get the header included (via stdafx.h or directly) doesn't really matter.Woodworker
This issue has been acknowledged by the author of the DirectXTK library.Lungworm
S
13

I have legacy projects and I compared the project settings side by side, finally I successfully built the new project by setting: Configuration Properties > C/C++ > Language > Conformance mode = No

Stay answered 1/9, 2018 at 1:28 Comment(1)
I personally prefer the suggestion from @Lungworm that it's actually just the /Zc:twoPhase- compiler option that you want to use to get the compiler to agree with the WRL source.Woundwort
F
13

When you use a dependent template name, you have to use a template keyword, for example:

foo.template bar<T>();

Till some moment MSVC was not strict about using typename and template disambiguators, but after an update the rules have changed.

Flection answered 15/8, 2018 at 19:19 Comment(2)
This is the solution. Just have to find where the error originates...lol.Autorotation
It shows you the line number. Check what's there. Probably you should either update these headers or play with compiler switches to temporarily restore old parsing mode.Flection
S
13

I have legacy projects and I compared the project settings side by side, finally I successfully built the new project by setting: Configuration Properties > C/C++ > Language > Conformance mode = No

Stay answered 1/9, 2018 at 1:28 Comment(1)
I personally prefer the suggestion from @Lungworm that it's actually just the /Zc:twoPhase- compiler option that you want to use to get the compiler to agree with the WRL source.Woundwort
B
1

The problem is in the Windows Runtime Library and some change to Visual Studio broke it. I have the same issue on this laptop which is updated to 15.8.2, my machine at home running an earlier version does not do this, since the exact same code compiles on my other machine, it's got to be a bug in VS, or a change required in WRL/event class.

EDIT: Fix to the return values above worked, bug is in the SDK, you should NOT disable /permissive- as this enables protection against Spectre and other security enhancements.

Byrnie answered 1/9, 2018 at 18:13 Comment(3)
There is neither a bug in the SDK nor in the compiler. What changed in the compiler is, that 15.8.0 introduced two-phase name lookup. You can disable two-phase name lookup using the /Zc:twoPhase- compiler option. /permissive- automatically opts into two-phase name lookup. You can combine both flags to get the compiler to agree with the WRL source. /permissive- does not have anything to do with guarding against Spectre.Lungworm
Good additional info. Also, check this blog about the permissive changes made to mitigate spectre. blogs.msdn.microsoft.com/vcblog/2018/04/09/…Byrnie
The /permissive- compiler option controls, what C++ source code the compiler accepts as valid input. This is strictly confined to the compiler frontend. The /Qspectre compiler option, on the other hand, affects code generation, i.e. the compiler backend. It is unclear to me, what effect the /permissive- option were to have on Spectre mitigation, or any other security enhancement really. The blog post doesn't suggest any relationship anyway. What am I missing?Lungworm

© 2022 - 2024 — McMap. All rights reserved.