From e17409548013d3eb53bfb5f5afd5009376833b06 Mon Sep 17 00:00:00 2001 From: Klemens Date: Sat, 22 Jul 2023 13:42:08 +0800 Subject: [PATCH] include & warning fixes Closes #12 & #13 --- CMakeLists.txt | 1 + .../async/io/buffers/any_dynamic_buffer.hpp | 4 +++ include/boost/async/io/endpoint.hpp | 6 ++-- src/io/popen.cpp | 2 +- src/io/process.cpp | 2 +- src/io/resolver.cpp | 3 ++ src/io/socket.cpp | 30 ++++++++++--------- test/io/ssl.cpp | 3 +- 8 files changed, 31 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab738977..01762452 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,7 @@ target_link_libraries(boost_async PUBLIC Boost::system Threads::Threads) target_compile_definitions(boost_async PRIVATE BOOST_ASYNC_SOURCE=1 ) +target_compile_definitions(boost_async PUBLIC BOOST_PROCESS_USE_STD_FS=1) if (BOOST_ASYNC_USE_BOOST_CONTAINER) target_link_libraries(boost_async PUBLIC Boost::container) diff --git a/include/boost/async/io/buffers/any_dynamic_buffer.hpp b/include/boost/async/io/buffers/any_dynamic_buffer.hpp index a44a2e24..87475d81 100644 --- a/include/boost/async/io/buffers/any_dynamic_buffer.hpp +++ b/include/boost/async/io/buffers/any_dynamic_buffer.hpp @@ -15,6 +15,10 @@ #include #include #include + +#include + + #include namespace boost::async::io::buffers { diff --git a/include/boost/async/io/endpoint.hpp b/include/boost/async/io/endpoint.hpp index 567b15ec..0e1d86ce 100644 --- a/include/boost/async/io/endpoint.hpp +++ b/include/boost/async/io/endpoint.hpp @@ -16,6 +16,8 @@ #include #include +#include + namespace boost::async::detail { @@ -32,7 +34,7 @@ struct endpoint; struct stream_socket; -#if __GNUC__ +#if __GNUC__ && !defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsubobject-linkage" #endif @@ -185,7 +187,7 @@ struct endpoint protocol_type::type_t type_ = static_cast(0); }; -#if __GNUC__ +#if __GNUC__ && !defined(__clang__) #pragma GCC diagnostic pop #endif diff --git a/src/io/popen.cpp b/src/io/popen.cpp index fadf8bfb..46c2f952 100644 --- a/src/io/popen.cpp +++ b/src/io/popen.cpp @@ -71,7 +71,7 @@ system::result popen::running() { system::error_code ec; auto res = popen_.running(ec); - return ec ? ec : system::result(res); + return ec ? system::result(system::in_place_error, ec) : system::result(res); } system::result popen::close() diff --git a/src/io/process.cpp b/src/io/process.cpp index 937060d2..20e1ad45 100644 --- a/src/io/process.cpp +++ b/src/io/process.cpp @@ -81,7 +81,7 @@ system::result process::running() { system::error_code ec; auto res = process_.running(ec); - return ec ? ec : system::result(res); + return ec ? system::result(system::in_place_error, ec) : system::result(res); } } \ No newline at end of file diff --git a/src/io/resolver.cpp b/src/io/resolver.cpp index a68650cb..1190bdd0 100644 --- a/src/io/resolver.cpp +++ b/src/io/resolver.cpp @@ -7,6 +7,9 @@ #include +#include +#include + namespace boost::async::io { diff --git a/src/io/socket.cpp b/src/io/socket.cpp index 9601c03a..5b84df1c 100644 --- a/src/io/socket.cpp +++ b/src/io/socket.cpp @@ -86,20 +86,22 @@ system::result socket::bytes_readable() return ec ? ec : system::result(opt.get()); } -#define DEFINE_OPTION(Name, Type) \ -system::result socket::set_##Name(Type value) \ -{ \ - system::error_code ec; \ - socket_.set_option(asio::socket_base::Name(value), ec); \ - return ec ? ec : system::result{}; \ -} \ - \ -system::result socket::get_##Name() const \ -{ \ - system::error_code ec; \ - asio::socket_base::Name opt; \ - socket_.get_option(opt, ec); \ - return ec ? ec : system::result(opt.value()); \ +#define DEFINE_OPTION(Name, Type) \ +system::result socket::set_##Name(Type value) \ +{ \ + system::error_code ec; \ + socket_.set_option(asio::socket_base::Name(value), ec); \ + return ec ? ec : system::result{}; \ +} \ + \ +system::result socket::get_##Name() const \ +{ \ + system::error_code ec; \ + asio::socket_base::Name opt; \ + socket_.get_option(opt, ec); \ + return ec \ + ? system::result(system::in_place_error, ec) \ + : system::result(system::in_place_value, opt.value()); \ } DEFINE_OPTION(debug, bool); diff --git a/test/io/ssl.cpp b/test/io/ssl.cpp index b175290b..bd03ba3f 100644 --- a/test/io/ssl.cpp +++ b/test/io/ssl.cpp @@ -26,7 +26,6 @@ CO_TEST_CASE("ssl") CHECK_MESSAGE(conn, conn.error().message()); CHECK_NOTHROW(co_await ss.async_handshake(async::io::ssl_stream::handshake_type::client).value()); - co_await ss; - + co_await ss.write_some("GET"); CHECK_NOTHROW(co_await ss.async_shutdown()); } \ No newline at end of file