Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error C2102: '&' requires l-value, VS2019. How to fix?

Tags:

c++

directx

I am using DirectX 11 and trying to load variables locally in scope using XMLoadFloat4. I am doing a lot of it and names are pretty long so I don't want to create bunch of local variables, however with code like this:

XMStoreFloat4(&vertices[0].normal, XMVector3Cross(
        XMLoadFloat4(&(vertices[2].position - vertices[0].position)),
        XMLoadFloat4(&(vertices[0].position - vertices[1].position))
        ));

I'm getting C2102. Do you know elegant way to create reference in place like this?

like image 452
Mikołaj Gogola Avatar asked Mar 01 '23 20:03

Mikołaj Gogola


1 Answers

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

like image 59
Jack1488 Avatar answered Mar 12 '23 10:03

Jack1488