How to get around the warning “rvalue used as lvalue”?

前端 未结 1 691
臣服心动
臣服心动 2021-01-12 11:56

I\'m using this tutorial, but when I compile the code from it:

D3DXMatrixLookAtLH(
    &matView,
    &D3DXVECTOR3(0.0f, 10.0f, 0.0f), // warning C423         


        
相关标签:
1条回答
  • 2021-01-12 12:46

    You are taking the address of a temporary. You can't do that. Declare your vectors beforehand:

    D3DXVECTOR3 a(0.0f, 10.0f, 0.0f)
                ,b(0.0f, 0.0f, 0.0f)
                ,c(0.0f, 0.0f, 1.0f);
    D3DXMatrixLookAtLH(&matView, &a, &b, &c);
    

    Note that I ignored your "without additional lines of code?" requirement, because that's a stupid requirement.

    0 讨论(0)
提交回复
热议问题