Tbone281
Tbone281

Reputation: 91

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

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.

Upvotes: 5

Views: 8856

Answers (3)

Aaron Stackpole
Aaron Stackpole

Reputation: 53

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.

Upvotes: 1

Peng DU
Peng DU

Reputation: 145

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

Upvotes: 13

Evg
Evg

Reputation: 26302

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.

Upvotes: 14

Related Questions