Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do all C++ compilers support the async/await keywords?

I want to use async/await syntax in C++ (UE4 framework), but due to cross-platform code I not sure that is possible... Or possible? If yes, how can I use it?

And also there are await and __await (resumable, yield and __yield_value also) keywords that highlighted in Visual Studio. What's difference? Maybe not all compilers supports this keywords or supports separately?

gcc, clang are accepts it? Or not accepts and I can just use macros for each platform individually.

like image 405
Artem Selivanov Avatar asked Aug 23 '16 16:08

Artem Selivanov


1 Answers

async and await are language extensions proposed by Microsoft with several revisions, but current is N4134. This has not yet accepted into the standard.

The proposal is opposed by many like http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0158r0.html due to not being completely baked and having not been explored fully in a TS and there's competing proposals like N3985 which proposes coroutines that can be implemented within the existing language standard.

To my knowledge, the only compiler that actually supports async/await is MS Visual Studio.

As an update, clang 5.0 has support for the current draft co-routines proposal https://isocpp.org/files/papers/N4663.pdf which has now been accepted as a TS and is progressing with an eye toward the C++20 standard.

like image 200
Charlie Avatar answered Oct 20 '22 04:10

Charlie