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

Artem Selivanov picture Artem Selivanov · Aug 23, 2016 · Viewed 8.4k times · Source

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.

Answer

Charlie picture Charlie · Aug 23, 2016

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.