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. Including qfutureinterface.h cause compile error "Error C7683 you cannot create a reference to 'void'"
Forum Updated to NodeBB v4.3 + New Features

Including qfutureinterface.h cause compile error "Error C7683 you cannot create a reference to 'void'"

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 5 Posters 464 Views 1 Watching
  • 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.
  • L Offline
    L Offline
    LJN_leaper
    wrote on last edited by
    #1

    If I include qfutureinterface.h in a regular Qt C++ project, there will be no errors. But now I am including this header file in a Qt c++/cli project, and it cause compile error when build "Error C7683 you cannot create a reference to 'void'". I read the header file and find a method take a parameter of "const QVector<void> &" type, so I guess this is the reason of problem. Because I have tried adding a local QVector<void> variable in my own method for test purpose which led to the same compile error. Is this a bug of Qt?

    I use Qt 5.9.4 with Visual Studio 2022.

    ca6a3acd-fb28-4c2f-8601-29a3b2ed1af2-image.png

    1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

      I would guess this ancient Qt version is using a c++ construct which is no longer accepted with a recent compiler. Either upgrade Qt or look into a more recent version of this header to see if it was fixed so you can backport it by yourself.

      I Offline
      I Offline
      IgKh
      wrote on last edited by
      #6

      That's a very interesting question, thanks!

      @Christian-Ehrlicher said in Including qfutureinterface.h cause compile error "Error C7683 you cannot create a reference to 'void'":

      a more recent version of this header to see if it was fixed

      No dice on that, the void specialization is there even up to Qt 6.9 - https://github.com/qt/qtbase/blob/dev/src/corelib/thread/qfutureinterface.h#L510

      @Christian-Ehrlicher said in Including qfutureinterface.h cause compile error "Error C7683 you cannot create a reference to 'void'":

      a c++ construct which is no longer accepted with a recent compiler

      The thing is, that void references are not, and never were, valid in C++. However they are not an error in any compiler I checked if they only come up in an uninstantiated template, including in explicit specialization as long as it doesn't actually get used. Including in MSVC in regular C++ mode: https://godbolt.org/z/rroMY86zb

      But the moment MSVC gets put into C++/CLI mode, it becomes an error - https://godbolt.org/z/eWeEvPqK9

      I don't know nearly anything about C++/CLI but it appears that it has some different rules regarding template instantiation (though it shouldn't be that surprising, hybrid languages like C++/CLI and Objective-C++ are not C++, they are different languages). Some template trickery that C++ uses appears to be incompatible with those rules.

      @LJN_leaper I'm not sure where that leaves you. Maybe you can file a bug report, but direct use of QFutureInterface is already a quite advanced use case. Your best bet is probably to try and isolate its' use into a pure C++ file of your project.

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi and welcome to devnet,

        A shot in the dark, is this project setting the C++ standard to an old value ?

        On a side note, 5.9 is more than outdated, if possible you should consider updating to at least 5.15 if not Qt 6.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        L 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi and welcome to devnet,

          A shot in the dark, is this project setting the C++ standard to an old value ?

          On a side note, 5.9 is more than outdated, if possible you should consider updating to at least 5.15 if not Qt 6.

          L Offline
          L Offline
          LJN_leaper
          wrote on last edited by LJN_leaper
          #3

          @SGaist Hi, I have tried updating C++ Language Standard from "Default (ISO C++14 Standard)" to "ISO C++20 Standard (/std:c++20)", but the error still exists. Thank you for suggestion on updating Qt, but my leader refuses.

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            I would guess this ancient Qt version is using a c++ construct which is no longer accepted with a recent compiler. Either upgrade Qt or look into a more recent version of this header to see if it was fixed so you can backport it by yourself.

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

            I 1 Reply Last reply
            1
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by
              #5

              You could try explicitly setting c++11 as the standard in your project. This is in PRO file:

              CONFIG += c++11
              

              or the equivalent.

              1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                I would guess this ancient Qt version is using a c++ construct which is no longer accepted with a recent compiler. Either upgrade Qt or look into a more recent version of this header to see if it was fixed so you can backport it by yourself.

                I Offline
                I Offline
                IgKh
                wrote on last edited by
                #6

                That's a very interesting question, thanks!

                @Christian-Ehrlicher said in Including qfutureinterface.h cause compile error "Error C7683 you cannot create a reference to 'void'":

                a more recent version of this header to see if it was fixed

                No dice on that, the void specialization is there even up to Qt 6.9 - https://github.com/qt/qtbase/blob/dev/src/corelib/thread/qfutureinterface.h#L510

                @Christian-Ehrlicher said in Including qfutureinterface.h cause compile error "Error C7683 you cannot create a reference to 'void'":

                a c++ construct which is no longer accepted with a recent compiler

                The thing is, that void references are not, and never were, valid in C++. However they are not an error in any compiler I checked if they only come up in an uninstantiated template, including in explicit specialization as long as it doesn't actually get used. Including in MSVC in regular C++ mode: https://godbolt.org/z/rroMY86zb

                But the moment MSVC gets put into C++/CLI mode, it becomes an error - https://godbolt.org/z/eWeEvPqK9

                I don't know nearly anything about C++/CLI but it appears that it has some different rules regarding template instantiation (though it shouldn't be that surprising, hybrid languages like C++/CLI and Objective-C++ are not C++, they are different languages). Some template trickery that C++ uses appears to be incompatible with those rules.

                @LJN_leaper I'm not sure where that leaves you. Maybe you can file a bug report, but direct use of QFutureInterface is already a quite advanced use case. Your best bet is probably to try and isolate its' use into a pure C++ file of your project.

                1 Reply Last reply
                1
                • L LJN_leaper has marked this topic as solved on

                • Login

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