Can I use coroutines together with Qt?
-
Hi,
I'm using At 6.22 and QtCreator at the moment. And I want to use coroutines. I did search on this topic, but it is not clear to me if I there is a compiler that does support coroutines and that can be used with QtCreater and Qt 6.22.Any help and info is welcome!
-
Since QtCreator is just an IDE and Qt just a c++ library I don't see why it should not be possible to use a c++ feature when the used compiler supports it.
btw: There is no QtCreator 6.22 nor Qt 6.22 anywhere out in the wild... just MS-DOS 6.22 -
Sorry that was a bit slopy of me!
It is Qt 6.2.2 and QtCreator 6.0.2.
I know it will depend on the compiler and not Qt. But the problem is that for coroutines one needs a recent compiler. And when manging the kits in QtCreator I do not see very recent compilers.
I can select Microsoft Visual C++ Compiler 17.1.32210.238 (x86) as the latest MSVC compiler. And according some list on the internet I need version 19.28.
I assume I need to compare the first digits. So the one of QtCreator is way to old.
Using the Qt Maintanance tool I do not see a newer one.So what are my options here?
-
Hi,
The Qt Creator version has nothing to do with your issue. Install a recent enough version of Visual Studio and use it to build your project. Backward compatibility has started with VS2017.
-
I have installed the latest Visual Studio tools and compiler.
And the naming of the MSVC compiler is different in both IDEs.
In VisualStudio they are named MSVC v142 MSVC v143 etc.
In QtCreator they are called like "Microsoft Visual C++ Compiler 17.1.32210.238".
So I did (and do) not see the relation between them.So I displayed the _MSC_VER value and it turned out to be 1931. What does that mean? What is the relation with 17.1.32210.238 (that is the one I'm using).
Coroutines need version 19.28. I guess that 1931 is like 19.31 and thus ok?These MSVC compiler version numbers are very confusing!
-
@Simmania said in Can I use coroutines together with Qt?:
In VisualStudio they are named MSVC v142 MSVC v143 etc.
In QtCreator they are called like "Microsoft Visual C++ Compiler 17.1.32210.238".I think these are two different (legitimate) numbering/naming schemes, "MSVC++ version" vs "_MSC_VER". See the table at https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B, MSVC++ versions section, e.g.
MSVC++ version .......... _MSC_VER
14.31 .................... 1931 (Visual Studio 2022 Version 17.1)
So that version seems to have 4 numbers: 14.x, 19.x, 2022 & 17.x :)
-
@Simmania a MSC VER of 1931 is according to wikipedia Visual Studio 2022 which has a very good C++20 support. So C++ wise you should be able to use the coroutine stuff defined in C++20. How this works with Qt I cannot tell as I haven’t used them yet.
-
OK, I think I understand the compiler naming now.
One more thing. In MSVC I need to specify which C++ standard to use (e.g C++ 17 or C++ 20).
I do not see such a setting in QtCreator. Is that not needed?I'm asking because the coroutine keywords like co_await or not recognized when using
#include <coroutine> -
@Simmania said in Can I use coroutines together with Qt?:
I do not see such a setting in QtCreator
This is set in pro file if you use qmake:
CONFIG += c++20
If you use CMake it is:
set(CMAKE_CXX_STANDARD 20)