Skip to content

Commit

Permalink
include & warning fixes
Browse files Browse the repository at this point in the history
Closes #12 & #13
  • Loading branch information
klemens-morgenstern committed Aug 1, 2023
1 parent abe9d85 commit e174095
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 20 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions include/boost/async/io/buffers/any_dynamic_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <boost/async/io/buffers/mutable_buffer_span.hpp>
#include <boost/async/io/buffers/range.hpp>
#include <boost/async/io/buffers/concepts.hpp>

#include <boost/asio/detail/socket_types.hpp>


#include <cstdlib>

namespace boost::async::io::buffers {
Expand Down
6 changes: 4 additions & 2 deletions include/boost/async/io/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <boost/static_string.hpp>
#include <boost/system/result.hpp>

#include <span>

namespace boost::async::detail
{

Expand All @@ -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
Expand Down Expand Up @@ -185,7 +187,7 @@ struct endpoint
protocol_type::type_t type_ = static_cast<protocol_type::type_t>(0);
};

#if __GNUC__
#if __GNUC__ && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/io/popen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ system::result<bool> popen::running()
{
system::error_code ec;
auto res = popen_.running(ec);
return ec ? ec : system::result<bool>(res);
return ec ? system::result<bool>(system::in_place_error, ec) : system::result<bool>(res);
}

system::result<void> popen::close()
Expand Down
2 changes: 1 addition & 1 deletion src/io/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ system::result<bool> process::running()
{
system::error_code ec;
auto res = process_.running(ec);
return ec ? ec : system::result<bool>(res);
return ec ? system::result<bool>(system::in_place_error, ec) : system::result<bool>(res);
}

}
3 changes: 3 additions & 0 deletions src/io/resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#include <boost/async/io/resolver.hpp>

#include <boost/asio/deferred.hpp>
#include <boost/system/result.hpp>

namespace boost::async::io
{

Expand Down
30 changes: 16 additions & 14 deletions src/io/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,22 @@ system::result <std::size_t> socket::bytes_readable()
return ec ? ec : system::result<std::size_t>(opt.get());
}

#define DEFINE_OPTION(Name, Type) \
system::result<void> socket::set_##Name(Type value) \
{ \
system::error_code ec; \
socket_.set_option(asio::socket_base::Name(value), ec); \
return ec ? ec : system::result<void>{}; \
} \
\
system::result<Type> socket::get_##Name() const \
{ \
system::error_code ec; \
asio::socket_base::Name opt; \
socket_.get_option(opt, ec); \
return ec ? ec : system::result<Type>(opt.value()); \
#define DEFINE_OPTION(Name, Type) \
system::result<void> socket::set_##Name(Type value) \
{ \
system::error_code ec; \
socket_.set_option(asio::socket_base::Name(value), ec); \
return ec ? ec : system::result<void>{}; \
} \
\
system::result<Type> socket::get_##Name() const \
{ \
system::error_code ec; \
asio::socket_base::Name opt; \
socket_.get_option(opt, ec); \
return ec \
? system::result<Type>(system::in_place_error, ec) \
: system::result<Type>(system::in_place_value, opt.value()); \
}

DEFINE_OPTION(debug, bool);
Expand Down
3 changes: 1 addition & 2 deletions test/io/ssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

0 comments on commit e174095

Please sign in to comment.