diff --git a/include/boost/asio/detail/config.hpp b/include/boost/asio/detail/config.hpp
index 65f598c557..596a977ea7 100644
--- a/include/boost/asio/detail/config.hpp
+++ b/include/boost/asio/detail/config.hpp
@@ -1897,17 +1897,17 @@
 #    endif // defined(_RESUMABLE_FUNCTIONS_SUPPORTED)
 #   endif // (_MSC_FULL_VER >= 190023506)
 #  elif defined(__clang__)
-#   if (__cplusplus >= 201703) && (__cpp_coroutines >= 201703)
+#   if (__cplusplus >= 201703) && defined(__cpp_coroutines) && (__cpp_coroutines >= 201703)
 #    if __has_include(<experimental/coroutine>)
 #     define BOOST_ASIO_HAS_CO_AWAIT 1
 #    endif // __has_include(<experimental/coroutine>)
-#   endif // (__cplusplus >= 201703) && (__cpp_coroutines >= 201703)
+#   endif // (__cplusplus >= 201703) && defined(__cpp_coroutines) && (__cpp_coroutines >= 201703)
 #  elif defined(__GNUC__)
-#   if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
+#   if (__cplusplus >= 201709) && defined(__cpp_impl_coroutine) && (__cpp_impl_coroutine >= 201902)
 #    if __has_include(<coroutine>)
 #     define BOOST_ASIO_HAS_CO_AWAIT 1
 #    endif // __has_include(<coroutine>)
-#   endif // (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
+#   endif // (__cplusplus >= 201709) && defined(__cpp_impl_coroutine) && (__cpp_impl_coroutine >= 201902)
 #  endif // defined(__GNUC__)
 # endif // !defined(BOOST_ASIO_DISABLE_CO_AWAIT)
 #endif // !defined(BOOST_ASIO_HAS_CO_AWAIT)
@@ -1921,11 +1921,11 @@
 #   endif // (_MSC_VER >= 1928) && (_MSVC_LANG >= 201705)
 #  endif // defined(BOOST_ASIO_MSVC)
 #  if defined(__GNUC__)
-#   if (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
+#   if (__cplusplus >= 201709) && defined(__cpp_impl_coroutine) && (__cpp_impl_coroutine >= 201902)
 #    if __has_include(<coroutine>)
 #     define BOOST_ASIO_HAS_STD_COROUTINE 1
 #    endif // __has_include(<coroutine>)
-#   endif // (__cplusplus >= 201709) && (__cpp_impl_coroutine >= 201902)
+#   endif // (__cplusplus >= 201709) && defined(__cpp_impl_coroutine) && (__cpp_impl_coroutine >= 201902)
 #  endif // defined(__GNUC__)
 # endif // !defined(BOOST_ASIO_DISABLE_STD_COROUTINE)
 #endif // !defined(BOOST_ASIO_HAS_STD_COROUTINE)