Including qfutureinterface.h cause compile error "Error C7683 you cannot create a reference to 'void'"
-
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.
-
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.
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/rroMY86zbBut 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. -
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.
-
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.
@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.
-
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 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.
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/rroMY86zbBut 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. -