如何绕过警告“右值用作左值”?
我正在使用本教程,但是当我从中编译代码时:
D3DXMatrixLookAtLH(
&matView,
&D3DXVECTOR3(0.0f, 10.0f, 0.0f), // warning C4238
&D3DXVECTOR3(0.0f, 0.0f, 0.0f), // warning C4238
&D3DXVECTOR3(0.0f, 0.0f, 1.0f) // warning C4238
);
我得到:
警告 C4238:使用非标准扩展:类右值用作左值
无需额外代码行即可执行此操作的正确(无警告)方法是什么?
另外,我想知道这行代码有什么不好?如果它工作得很好,为什么它甚至会发出警告?或者说是……?
I'm using this tutorial, but when I compile the code from it:
D3DXMatrixLookAtLH(
&matView,
&D3DXVECTOR3(0.0f, 10.0f, 0.0f), // warning C4238
&D3DXVECTOR3(0.0f, 0.0f, 0.0f), // warning C4238
&D3DXVECTOR3(0.0f, 0.0f, 1.0f) // warning C4238
);
I get:
warning C4238: nonstandard extension used : class rvalue used as lvalue
What is the proper (warningless) way of doing this without additional lines of code?
Also, I'm wondering what is so bad about that line of code? Why does it even give warning if it works just fine? Or does it...?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在获取临时地址。你不能那样做。预先声明你的向量:
请注意,我忽略了你的“没有额外的代码行?”要求,因为这是一个愚蠢的要求。
You are taking the address of a temporary. You can't do that. Declare your vectors beforehand:
Note that I ignored your "without additional lines of code?" requirement, because that's a stupid requirement.