Search code examples
c++windowsvisual-studiowrl

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.


Solution

  • 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