microsoft / DirectXTK12

The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++
https://walbourn.github.io/directx-tool-kit-for-directx-12/
MIT License
1.5k stars 404 forks source link

XM_CONSTEXPR broken since 10.0.14393 December commit #16

Closed ChrisKing340 closed 7 years ago

ChrisKing340 commented 7 years ago

Since 10.0.14393 December commit have been unable to compile with errors in files: c:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um\DirectXMath.h c:\program files (x86)\windows kits\10\include\10.0.14393.0\um\directxpackedvector.h System: DxDiag Version: 10.00.14393.0000 64bit Unicode Visual Studio Community 2015 (14.0.23107.0 D14REL) Nvidia Driver 376.33 GTX 970

Build state is Debug x64 35 errors, all with XM_CONSTEXPR

From: c:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um\DirectXMath.h

#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define XM_CONSTEXPR
#else
#define XM_CONSTEXPR constexpr
#endif

for constexpr, it appears the code is not a constant expression (in first error fDegrees is not constant) Chuck, This may not be the right team to ask about it but how did you deal with this? Hate to ask, cant figure it out on my own likely means I did something stupid. Kind regards

First 3 for reference:

First error: Severity Code Description Project File Line Error (active) constexpr function return is non-constant DirectXTK12 c:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um\DirectXMath.h 268 inline XM_CONSTEXPR float XMConvertToRadians(float fDegrees) { return fDegrees * (XM_PI / 180.0f); } Second error: Severity Code Description Project File Line Error (active) constexpr function return is non-constant DirectXTK12 c:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um\DirectXMath.h 269 `inline XM_CONSTEXPR float XMConvertToDegrees(float fRadians) { return fRadians * (180.0f / XM_PI); }

Third error: Severity Code Description Project File Line Error C2476 'constexpr' constructor does not initialize all members DirectXTK12 c:\program files (x86)\windows kits\10\include\10.0.14393.0\um\directxpackedvector.h 50 XM_CONSTEXPR XMCOLOR(uint32_t Color) : c(Color) {}`

walbourn commented 7 years ago

There are two possible issues here:

(1) There are known issues with the VS 2015 "IntelliSense" compiler and DirectXMath 3.09's use of constexpr. These are only IntelliSense errors and do not cause compile errors or warnings during build.

(2) There is a known issue with the VS 2015 RTM C++ compiler w.r.t. to constexpr. These are fixed if you move to Update 1 or later (the current verison is VS 2015 Update 3).

There is a fix for first issue is in DirectXMath 3.10, as well as a workaround for VS 2015 RTM (which treats it the same as VS 2013 which doesn't support constexpr). A pre-release is availble here.

DirectXMath issues should be directed to that GitHub project.

ChrisKing340 commented 7 years ago

Thanks Chuck, fixed now. I will start watching the Git for DirectXMath as well. BTW, great work on TK12