d3dcoder / d3d12book

Sample code for the book "Introduction to 3D Game Programming with DirectX 12"
1.47k stars 571 forks source link

Compiler errors on Box example #26

Open velik97 opened 3 years ago

velik97 commented 3 years ago

Got a lot of compiler errors when trying to debug Box example from Chapter 6 Started from empty C++ project for Windows, VS 2019

Build started... 1>------ Build started: Project: Test, Configuration: Debug Win32 ------ 1>BoxApp.cpp 1>E:\Documents\Test\BoxApp.cpp(197): error C2102: '&' requires l-value 1>E:\Documents\Test\BoxApp.cpp(204): error C2102: '&' requires l-value 1>E:\Documents\Test\BoxApp.cpp(205): error C2102: '&' requires l-value 1>E:\Documents\Test\BoxApp.cpp(189): error C2102: '&' requires l-value 1>E:\Documents\Test\BoxApp.cpp(215): error C2102: '&' requires l-value 1>d3dApp.cpp 1>E:\Documents\Test\Common\d3dApp.cpp(199): error C2102: '&' requires l-value 1>E:\Documents\Test\Common\d3dApp.cpp(216): error C2102: '&' requires l-value 1>E:\Documents\Test\Common\d3dApp.cpp(547,77): error C2664: 'HANDLE CreateEventExW(LPSECURITY_ATTRIBUTES,LPCWSTR,DWORD,DWORD)': cannot convert argument 2 from 'bool' to 'LPCWSTR' 1>E:\Documents\Test\Common\d3dApp.cpp(547,47): message : Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast 1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\synchapi.h(647,1): message : see declaration of 'CreateEventExW' 1>d3dUtil.cpp 1>E:\Documents\Test\Common\d3dUtil.cpp(30,5): warning C4244: 'argument': conversion from 'std::streamoff' to 'SIZE_T', possible loss of data 1>E:\Documents\Test\Common\d3dUtil.cpp(48): error C2102: '&' requires l-value 1>E:\Documents\Test\Common\d3dUtil.cpp(58): error C2102: '&' requires l-value 1>E:\Documents\Test\Common\d3dUtil.cpp(70,32): warning C4244: '=': conversion from 'UINT64' to 'LONG_PTR', possible loss of data 1>E:\Documents\Test\Common\d3dUtil.cpp(76): error C2102: '&' requires l-value 1>E:\Documents\Test\Common\d3dUtil.cpp(79): error C2102: '&' requires l-value 1>DDSTextureLoader.cpp 1>E:\Documents\Test\Common\DDSTextureLoader.cpp(1273): error C2102: '&' requires l-value 1>E:\Documents\Test\Common\DDSTextureLoader.cpp(1292): error C2102: '&' requires l-value 1>E:\Documents\Test\Common\DDSTextureLoader.cpp(1294): error C2102: '&' requires l-value 1>E:\Documents\Test\Common\DDSTextureLoader.cpp(1305): error C2102: '&' requires l-value 1>E:\Documents\Test\Common\DDSTextureLoader.cpp(1311): error C2102: '&' requires l-value 1>MathHelper.cpp 1>Generating Code... 1>Done building project "Test.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

JoeSwindell commented 3 years ago

Your build settings are wrong, look at the build settings in one of the existing settings and see what's different.

I believe offhand you need to switch at least your character set.

https://docs.microsoft.com/en-us/cpp/build/working-with-project-properties?view=msvc-160

Sere-Fu commented 3 years ago

I went into exactly the same problem, win10, vs2019. same procedures as indicated in the book.

ericschwarzkopf commented 3 years ago

This is caused by the c++ standard conformance check that is active in vs2019 (see https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-160). If you set the corresponding flag in the project settings to /permissive, the errors go away.

AriaMoKr commented 3 years ago

To add to @ericschwarzkopf in the Property Pages, Configuration Properties -> C/C++ -> Language -> Conformance mode: change from Yes (/permissive-) to No (/permissive)