我该如何修复 "&需要 l 值" [英] How can I fix "& requires l-value"

查看:18
本文介绍了我该如何修复 "&需要 l 值"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我创建了一个项目并复制了 本教程 在里面.当我尝试运行它时,它给了我这个错误:C2102 &需要左值 at

So, I created a project and copied this tutorial in it. When I tried to run it, it gave me this error: C2102 & requires l-value at

m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET));

我搜索了很多,但没有找到符合上下文的内容.我能做些什么来修复它?

I searched a lot but i found nothing that fits in the context. What can I do to fix it?

推荐答案

这与 问题 #652 DirectX-Graphics-Samples 存储库.

This is essentially the same build error reported under Issue #652 Error building D3D12MeshShaders (on VS 16.8.0 Preview 3.0) in the DirectX-Graphics-Samples repo.

我收到错误 C2102:&"在许多行上需要 l 值.通常是当 CD3DX12 构造函数直接与 & 一起使用时,例如 [...]

问题仍然存在,评论中给出了临时解决方法:

The issue is still open, with an interim workaround given in a comment:

像这样使用 r 值的地址 [...] 是不合规的代码.

The use of an address of an r-value like this [...] is non-conforming code.

Visual C++ 在这里发出警告 C4238,/W4 警告级别为 4,但大多数 VC 项目默认为级别 3,包括这些示例.[...] 看起来/permissive- 的最新 Visual C++ 更新已将此升级为错误.

Visual C++ emits a warning C4238 here with /W4 warning level 4, but most VC projects default to level 3 including these samples. [...] Looks like the latest Visual C++ updates for /permissive- have upgraded this to an error.

您现在可以通过更改一致性模式"禁用/permissive- 来解决此问题.否"在 C/C++ 中 ->语言项目设置.

You can work around this issue for now by disabling /permissive- by changing "Conformance Mode" to "No" in the C/C++ -> Language project settings.

这篇关于我该如何修复 "&需要 l 值"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆