coroutine C/C++ Origin: Application & API OSI layer 7 · Application Last updated 2 Dec 2026

error: 'co_await' / 'co_return' requires the compiler to be run with -fcoroutines (or <coroutine> not found)

Coroutine keywords were used without enabling C++20 coroutines or including the header.

Exact message you may see co_await requires coroutinescoroutines require -fcoroutinescoroutine header not foundunable to find the promise type
Seen on: C++ GCC Clang

Meaning

GCC 10 needs -fcoroutines in addition to -std=c++20; GCC 11 and later enable it with C++20. The header is <coroutine> (not <experimental/coroutine>), and a coroutine needs a promise type.

Common causes

  • -std=c++20 missing
  • GCC 10 without -fcoroutines
  • Old <experimental/coroutine> used with a new compiler
  • No promise_type for the return type

⚡ Quick fix

  1. Compile with -std=c++20 (and -fcoroutines on GCC 10)
  2. Include <coroutine>
  3. Return a type that defines promise_type

Detailed fix by platform

GCC

  1. g++ -std=c++20 -fcoroutines main.cpp

How to diagnose

  1. Std — c++20?
  2. Header — <coroutine>?
  3. Promise — promise_type defined?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

call of overloaded is ambiguous — C++: error: call of overloaded 'f(int)' is ambiguous (C/C++)call of overloaded is…cannot declare variable to be of abstract type — C++: error: cannot declare variable 'x' to be of abstract type 'Shape' (pure virtual functions) (C/C++)cannot declare variab…not a member of std — C++: error: 'optional' in namespace 'std' does not name a template type — wrong -std standard (C/C++)not a member of stdonly available with — C++: warning: structured bindings / inline variables only available with '-std=c++17' or '-std=gnu++17' (C/C++)only available withreference to is ambiguous — C++: error: reference to 'X' is ambiguous (using namespace std conflicts) (C/C++)reference to is ambig…std::format — error: 'format' is not a member of 'std' (<format> not found) (C/C++)std::formatunrecognized command-line option — g++: error: unrecognized command-line option '-std=c++20' (C/C++)unrecognized command-…coroutine

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.