chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.97k stars 1.22k forks source link

Fix complilation wth clang in C++17 mode with -Werror -Wundef #1467

Open cuavas opened 7 months ago

cuavas commented 7 months ago

clang 14 only defines __cpp_coroutines with -std=c++2a, it’s undefined with -std=c++17. This results in an undefined macro warning if you don’t check that it’s defined before comparing it to a literal with the -Wundef warning option:

In file included from asio/include/asio.hpp:18:
In file included from asio/include/asio/any_completion_executor.hpp:18:
asio/include/asio/detail/config.hpp:1317:39: error: '__cpp_coroutines' is not defined, evaluates to 0 [-Werror,-Wundef]
#    elif (__cplusplus >= 201703) && (__cpp_coroutines >= 201703)
                                      ^

This pull request adds the check to avoid the warning.