Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does the latest clang not define the feature test macro __cpp_coroutines?

#include <iostream>

int main() {
#if __has_include(<coroutine>)
    std::cout << "__has_include(<coroutine>)" << std::endl;
#endif

#if defined(__cpp_impl_coroutine)
    std::cout << "__cpp_impl_coroutine is defined." << std::endl;
#endif

#if defined(__cpp_coroutines)
    std::cout << "__cpp_coroutines is defined." << std::endl;
#else
    std::cout << "__cpp_coroutines IS NOT defined!" << std::endl;
#endif
}

My compiler is clang-18.1.0.

Build the code with clang++ -std=c++20 -stdlib=libc++ ./main.cpp, and the output is:

__has_include(<coroutine>)
__cpp_impl_coroutine is defined.
__cpp_coroutines IS NOT defined!

Why does the latest clang not define the feature test macro __cpp_coroutines?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

__cpp_coroutines is an outdated feature test macro, it was split into __cpp_lib_coroutine and __cpp_impl_coroutine before c++20 was standardised. You should use the up to date cpp reference pages for the latest information https://en.cppreference.com/w/cpp/feature_test

Clang seems to have stopped defining __cpp_coroutines since version 17 https://godbolt.org/z/nc1GhGGTo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading