C2102: '&' requires I-Value
-
Hi.
i found an old code at our system that have worked earlier. When i now try to comile it in QT, i get the "C2102: '&' requires -I-Value" error.
I read that in earlier versions of c++ this could have caused an warning, an later versions it is trigging error. Hense why it is working before, and not now.
Can anyone se a how to prevent this error with the following code?
realy appreciate all help i can get
-
Hi.
i found an old code at our system that have worked earlier. When i now try to comile it in QT, i get the "C2102: '&' requires -I-Value" error.
I read that in earlier versions of c++ this could have caused an warning, an later versions it is trigging error. Hense why it is working before, and not now.
Can anyone se a how to prevent this error with the following code?
realy appreciate all help i can get
So has a good answer for it: https://stackoverflow.com/questions/3674456/why-this-is-causing-c2102-requires-l-value
Because a::get_dummy() returns a unnamed temporary object (int pointer).
Object returned by function sit ontop of the stack frame and it is meaningless to get its address since it might be invalid after expression ends.-> don't try to pass the return value of QDomNodeList::at() as pointer but e..g as const ref.
-
Hi.
i found an old code at our system that have worked earlier. When i now try to comile it in QT, i get the "C2102: '&' requires -I-Value" error.
I read that in earlier versions of c++ this could have caused an warning, an later versions it is trigging error. Hense why it is working before, and not now.
Can anyone se a how to prevent this error with the following code?
realy appreciate all help i can get
@jorTry85 said in C2102: '&' requires I-Value:
When i now try to comile it in QT
Qt is not a compiler. You seem to be using MSVC compiler. That is where you you should be looking. I suggest you Google for
C2102
and read e.g. the stackoverflow posts. It looks like you either change the compiler options ("disabling/permissive-
") or better actually "fix". I believe it is telling you that those functions return a "temporary" object, so you shouldn't take its address, you should rather assign to a local variable and use that, or pass aconst
reference?