Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. C2102: '&' requires I-Value
Forum Updated to NodeBB v4.3 + New Features

C2102: '&' requires I-Value

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jorTry85
    wrote on last edited by
    #1

    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

    cc0bbd99-e26a-4a01-a6fa-0ac990bed1ed-image.png

    fd4f85a1-3283-4c2c-bdb9-cabe306504cf-image.png

    26f2a80f-c417-4f5a-b581-ea3a5696e51e-image.png

    02881a9a-e3bd-4fa1-89e5-96552826511e-image.png

    Christian EhrlicherC JonBJ 2 Replies Last reply
    0
    • J jorTry85

      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

      cc0bbd99-e26a-4a01-a6fa-0ac990bed1ed-image.png

      fd4f85a1-3283-4c2c-bdb9-cabe306504cf-image.png

      26f2a80f-c417-4f5a-b581-ea3a5696e51e-image.png

      02881a9a-e3bd-4fa1-89e5-96552826511e-image.png

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • J jorTry85

        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

        cc0bbd99-e26a-4a01-a6fa-0ac990bed1ed-image.png

        fd4f85a1-3283-4c2c-bdb9-cabe306504cf-image.png

        26f2a80f-c417-4f5a-b581-ea3a5696e51e-image.png

        02881a9a-e3bd-4fa1-89e5-96552826511e-image.png

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @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 a const reference?

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved