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.

Tbone281
  • 91
  • 1
  • 9
  • "Starting with stdafx" - maybe get rid of that one already, for a build with fewer surprises. – Jesper Juhl Aug 15 '18 at 18:39
  • Going down the list. Checking them off as I go. – Tbone281 Aug 15 '18 at 18:47
  • 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. – Tbone281 Aug 15 '18 at 18:55
  • 1
    @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. – MSalters Aug 16 '18 at 08:28
  • 2
    This [issue](https://github.com/Microsoft/DirectXTK/issues/142) has been acknowledged by the author of the DirectXTK library. – IInspectable Sep 11 '18 at 18:17

3 Answers3

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

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
Peng DU
  • 146
  • 3
  • 4
    I personally prefer the suggestion from @IInspectable 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. – Wyck Sep 17 '18 at 02:50
12

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.

Evg
  • 25,259
  • 5
  • 41
  • 83
  • This is the solution. Just have to find where the error originates...lol. – Tbone281 Aug 15 '18 at 19:21
  • 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. – Evg Aug 15 '18 at 19:25
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.

  • 2
    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-](https://learn.microsoft.com/en-us/cpp/build/reference/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. – IInspectable Sep 08 '18 at 09:01
  • Good additional info. Also, check this blog about the permissive changes made to mitigate spectre. https://blogs.msdn.microsoft.com/vcblog/2018/04/09/spectre-mitigation-changes-in-visual-studio-2017-version-15-7-preview-3/ – Aaron Stackpole Sep 09 '18 at 04:06
  • 3
    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? – IInspectable Sep 09 '18 at 05:32