protonscr

Error and warning occurred when building by VS2017

dxvkclosed build
doitsujin/dxvk#801 · opened 2018-12-07 by AnzhongHuang · updated 2018-12-07 · 5 comments · github
AAnzhongHuang 2018-12-07 github

I had a visual studio 2017 solution for dxvk. I found there are lots of warnings when building 64-bits solution, dxvk assigns size_t to int32, I can bear with those warnings, because they can be ignored by VS compiler configure.

But there is en error caused by the variable ID3D11DepthStencilView* d3d11Dsv in D3D10Device::OMGetRenderTargets is not initialized. I keep wanting to fix it.

Ddoitsujin maintainer 2018-12-07 github

Why would the compiler throw an error on that one? It is true that the compiler doesn't know that this code actually sets that variable when it is needed, but that doesn't make it invalid or wrong:

    m_context->OMGetRenderTargets(NumViews,
      ppRenderTargetViews ? d3d11Rtv : nullptr,
      ppDepthStencilView ? &d3d11Dsv : nullptr);

I'm a bit reluctant to add useless initialization code just to support MSVC, keep in mind that Windows is not really the target platform of DXVK and everything else compiles it just fine without even complaining.

AAnzhongHuang 2018-12-07 github

It doesn't need much change, but just change the declaration to ID3D11DepthStencilView* d3d11Dsv = nullptr;, it can save my time when I merging code.
It's not just for MSVC, but also for unifying the code style, it's the only case forgot to be initialization in DXVK.

Ddoitsujin maintainer 2018-12-07 github

My point is that the initialization is redundant and unnecessary, the array above it doesn't get initialized either. Doesn't MSVC complain about that as well?

Ddoitsujin maintainer 2018-12-07 github

Well anyway, I pushed some code to initialize the pointer. Please let me know if that fixes it.

AAnzhongHuang 2018-12-07 github

Thanks a lot, the error is fixed. And MSVC doesn't complain about the array, I agree with you, it's not necessary from the point of code logic, since it will be assigned soon. I think the error/warning checking of MSVC is too strict on potential data lost or uninitialized.

Nothing extracted yet.