Skip to content

Commit

Permalink
Fix build on Embarcadero C++Builder 10.3
Browse files Browse the repository at this point in the history
Double braces aren't necessary for list-initialization after a '=' sign.
  - https://en.cppreference.com/w/cpp/container/array#Example
  - https://www.boost.org/doc/libs/1_69_0/doc/html/array/rationale.html

In Embarcadero C++Builder 10.3 (`bcc32c`) that syntax fails to compile.
Change to single braces.

Also allow `BOOST_ASIO_HAS_HANDLER_HOOKS` to be enabled on the modern
[Clang-based](http://docwiki.embarcadero.com/RADStudio/Rio/en/Win32_Clang-enhanced_Compilers)
C++Builder compilers.
  • Loading branch information
tanzislam committed Mar 10, 2019
1 parent 54cdc73 commit a7d9701
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 53 deletions.
4 changes: 2 additions & 2 deletions example/cpp03/icmp/ipv4_header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ class ipv4_header
boost::asio::ip::address_v4 source_address() const
{
boost::asio::ip::address_v4::bytes_type bytes
= { { rep_[12], rep_[13], rep_[14], rep_[15] } };
= { rep_[12], rep_[13], rep_[14], rep_[15] };
return boost::asio::ip::address_v4(bytes);
}

boost::asio::ip::address_v4 destination_address() const
{
boost::asio::ip::address_v4::bytes_type bytes
= { { rep_[16], rep_[17], rep_[18], rep_[19] } };
= { rep_[16], rep_[17], rep_[18], rep_[19] };
return boost::asio::ip::address_v4(bytes);
}

Expand Down
4 changes: 2 additions & 2 deletions example/cpp03/porthopper/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class control_request
boost::array<boost::asio::mutable_buffer, 1> to_buffers()
{
boost::array<boost::asio::mutable_buffer, 1> buffers
= { { boost::asio::buffer(data_) } };
= { boost::asio::buffer(data_) };
return buffers;
}

Expand Down Expand Up @@ -137,7 +137,7 @@ class frame
boost::array<boost::asio::mutable_buffer, 1> to_buffers()
{
boost::array<boost::asio::mutable_buffer, 1> buffers
= { { boost::asio::buffer(data_) } };
= { boost::asio::buffer(data_) };
return buffers;
}

Expand Down
4 changes: 2 additions & 2 deletions include/boost/asio/detail/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,9 +1334,9 @@
# if (__GNUC__ >= 3)
# define BOOST_ASIO_HAS_HANDLER_HOOKS 1
# endif // (__GNUC__ >= 3)
# elif !defined(__BORLANDC__)
# elif !defined(__BORLANDC__) || defined(__clang__)
# define BOOST_ASIO_HAS_HANDLER_HOOKS 1
# endif // !defined(__BORLANDC__)
# endif // !defined(__BORLANDC__) || defined(__clang__)
# endif // !defined(BOOST_ASIO_DISABLE_HANDLER_HOOKS)
#endif // !defined(BOOST_ASIO_HAS_HANDLER_HOOKS)

Expand Down
2 changes: 1 addition & 1 deletion include/boost/asio/detail/impl/dev_poll_reactor.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void dev_poll_reactor::run(long usec, op_queue<operation>& ops)
lock.unlock();

// Block on the /dev/poll descriptor.
::pollfd events[128] = { { 0, 0, 0 } };
::pollfd events[128] = { 0, 0, 0 };
::dvpoll dp = { 0, 0, 0 };
dp.dp_fds = events;
dp.dp_nfds = 128;
Expand Down
20 changes: 10 additions & 10 deletions include/boost/asio/ip/impl/address_v6.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ address_v4 address_v6::to_v4() const
boost::asio::detail::throw_exception(ex);
}

address_v4::bytes_type v4_bytes = { { addr_.s6_addr[12],
addr_.s6_addr[13], addr_.s6_addr[14], addr_.s6_addr[15] } };
address_v4::bytes_type v4_bytes = { addr_.s6_addr[12],
addr_.s6_addr[13], addr_.s6_addr[14], addr_.s6_addr[15] };
return address_v4(v4_bytes);
}
#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
Expand Down Expand Up @@ -260,16 +260,16 @@ address_v6 address_v6::loopback() BOOST_ASIO_NOEXCEPT
address_v6 address_v6::v4_mapped(const address_v4& addr)
{
address_v4::bytes_type v4_bytes = addr.to_bytes();
bytes_type v6_bytes = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF,
v4_bytes[0], v4_bytes[1], v4_bytes[2], v4_bytes[3] } };
bytes_type v6_bytes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF,
v4_bytes[0], v4_bytes[1], v4_bytes[2], v4_bytes[3] };
return address_v6(v6_bytes);
}

address_v6 address_v6::v4_compatible(const address_v4& addr)
{
address_v4::bytes_type v4_bytes = addr.to_bytes();
bytes_type v6_bytes = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
v4_bytes[0], v4_bytes[1], v4_bytes[2], v4_bytes[3] } };
bytes_type v6_bytes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
v4_bytes[0], v4_bytes[1], v4_bytes[2], v4_bytes[3] };
return address_v6(v6_bytes);
}
#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
Expand Down Expand Up @@ -329,17 +329,17 @@ address_v4 make_address_v4(
}

address_v6::bytes_type v6_bytes = v6_addr.to_bytes();
address_v4::bytes_type v4_bytes = { { v6_bytes[12],
v6_bytes[13], v6_bytes[14], v6_bytes[15] } };
address_v4::bytes_type v4_bytes = { v6_bytes[12],
v6_bytes[13], v6_bytes[14], v6_bytes[15] };
return address_v4(v4_bytes);
}

address_v6 make_address_v6(
v4_mapped_t, const address_v4& v4_addr)
{
address_v4::bytes_type v4_bytes = v4_addr.to_bytes();
address_v6::bytes_type v6_bytes = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xFF, 0xFF, v4_bytes[0], v4_bytes[1], v4_bytes[2], v4_bytes[3] } };
address_v6::bytes_type v6_bytes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xFF, 0xFF, v4_bytes[0], v4_bytes[1], v4_bytes[2], v4_bytes[3] };
return address_v6(v6_bytes);
}

Expand Down
4 changes: 2 additions & 2 deletions test/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ void test()
#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
boost::array<char, 1024> array_data;
const boost::array<char, 1024>& const_array_data_1 = array_data;
boost::array<const char, 1024> const_array_data_2 = { { 0 } };
boost::array<const char, 1024> const_array_data_2 = { 0 };
#endif // defined(BOOST_ASIO_HAS_BOOST_ARRAY)
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
std::array<char, 1024> std_array_data;
const std::array<char, 1024>& const_std_array_data_1 = std_array_data;
std::array<const char, 1024> const_std_array_data_2 = { { 0 } };
std::array<const char, 1024> const_std_array_data_2 = { 0 };
#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
std::vector<char> vector_data(1024);
const std::vector<char>& const_vector_data = vector_data;
Expand Down
2 changes: 1 addition & 1 deletion test/ip/address_v4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void test()
// address_v4 constructors.

ip::address_v4 addr1;
const ip::address_v4::bytes_type const_bytes_value = { { 127, 0, 0, 1 } };
const ip::address_v4::bytes_type const_bytes_value = { 127, 0, 0, 1 };
ip::address_v4 addr2(const_bytes_value);
const unsigned long const_ulong_value = 0x7F000001;
ip::address_v4 addr3(const_ulong_value);
Expand Down
2 changes: 1 addition & 1 deletion test/ip/address_v6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void test()
// address_v6 constructors.

ip::address_v6 addr1;
const ip::address_v6::bytes_type const_bytes_value = { { 0 } };
const ip::address_v6::bytes_type const_bytes_value = { 0 };
ip::address_v6 addr2(const_bytes_value);

// address_v6 functions.
Expand Down
16 changes: 8 additions & 8 deletions test/read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2547,9 +2547,9 @@ void test_3_arg_boost_array_buffers_async_read()
boost::asio::io_context ioc;
test_stream s(ioc);
char read_buf[sizeof(read_data)];
boost::array<boost::asio::mutable_buffer, 2> buffers = { {
boost::array<boost::asio::mutable_buffer, 2> buffers = {
boost::asio::buffer(read_buf, 32),
boost::asio::buffer(read_buf) + 32 } };
boost::asio::buffer(read_buf) + 32 };

s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
Expand Down Expand Up @@ -2610,9 +2610,9 @@ void test_3_arg_std_array_buffers_async_read()
boost::asio::io_context ioc;
test_stream s(ioc);
char read_buf[sizeof(read_data)];
std::array<boost::asio::mutable_buffer, 2> buffers = { {
std::array<boost::asio::mutable_buffer, 2> buffers = {
boost::asio::buffer(read_buf, 32),
boost::asio::buffer(read_buf) + 32 } };
boost::asio::buffer(read_buf) + 32 };

s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
Expand Down Expand Up @@ -3205,9 +3205,9 @@ void test_4_arg_boost_array_buffers_async_read()
boost::asio::io_context ioc;
test_stream s(ioc);
char read_buf[sizeof(read_data)];
boost::array<boost::asio::mutable_buffer, 2> buffers = { {
boost::array<boost::asio::mutable_buffer, 2> buffers = {
boost::asio::buffer(read_buf, 32),
boost::asio::buffer(read_buf) + 32 } };
boost::asio::buffer(read_buf) + 32 };

s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
Expand Down Expand Up @@ -3549,9 +3549,9 @@ void test_4_arg_std_array_buffers_async_read()
boost::asio::io_context ioc;
test_stream s(ioc);
char read_buf[sizeof(read_data)];
std::array<boost::asio::mutable_buffer, 2> buffers = { {
std::array<boost::asio::mutable_buffer, 2> buffers = {
boost::asio::buffer(read_buf, 32),
boost::asio::buffer(read_buf) + 32 } };
boost::asio::buffer(read_buf) + 32 };

s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
Expand Down
16 changes: 8 additions & 8 deletions test/read_at.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3544,9 +3544,9 @@ void test_4_arg_boost_array_buffers_async_read_at()
boost::asio::io_context ioc;
test_random_access_device s(ioc);
char read_buf[sizeof(read_data)];
boost::array<boost::asio::mutable_buffer, 2> buffers = { {
boost::array<boost::asio::mutable_buffer, 2> buffers = {
boost::asio::buffer(read_buf, 32),
boost::asio::buffer(read_buf) + 32 } };
boost::asio::buffer(read_buf) + 32 };

s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
Expand Down Expand Up @@ -3643,9 +3643,9 @@ void test_4_arg_std_array_buffers_async_read_at()
boost::asio::io_context ioc;
test_random_access_device s(ioc);
char read_buf[sizeof(read_data)];
std::array<boost::asio::mutable_buffer, 2> buffers = { {
std::array<boost::asio::mutable_buffer, 2> buffers = {
boost::asio::buffer(read_buf, 32),
boost::asio::buffer(read_buf) + 32 } };
boost::asio::buffer(read_buf) + 32 };

s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
Expand Down Expand Up @@ -4637,9 +4637,9 @@ void test_5_arg_boost_array_buffers_async_read_at()
boost::asio::io_context ioc;
test_random_access_device s(ioc);
char read_buf[sizeof(read_data)];
boost::array<boost::asio::mutable_buffer, 2> buffers = { {
boost::array<boost::asio::mutable_buffer, 2> buffers = {
boost::asio::buffer(read_buf, 32),
boost::asio::buffer(read_buf) + 32 } };
boost::asio::buffer(read_buf) + 32 };

s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
Expand Down Expand Up @@ -5338,9 +5338,9 @@ void test_5_arg_std_array_buffers_async_read_at()
boost::asio::io_context ioc;
test_random_access_device s(ioc);
char read_buf[sizeof(read_data)];
std::array<boost::asio::mutable_buffer, 2> buffers = { {
std::array<boost::asio::mutable_buffer, 2> buffers = {
boost::asio::buffer(read_buf, 32),
boost::asio::buffer(read_buf) + 32 } };
boost::asio::buffer(read_buf) + 32 };

s.reset(read_data, sizeof(read_data));
memset(read_buf, 0, sizeof(read_buf));
Expand Down
16 changes: 8 additions & 8 deletions test/write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2294,9 +2294,9 @@ void test_3_arg_boost_array_buffers_async_write()
#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
boost::asio::io_context ioc;
test_stream s(ioc);
boost::array<boost::asio::const_buffer, 2> buffers = { {
boost::array<boost::asio::const_buffer, 2> buffers = {
boost::asio::buffer(write_data, 32),
boost::asio::buffer(write_data) + 32 } };
boost::asio::buffer(write_data) + 32 };

s.reset();
bool called = false;
Expand Down Expand Up @@ -2352,9 +2352,9 @@ void test_3_arg_std_array_buffers_async_write()
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
boost::asio::io_context ioc;
test_stream s(ioc);
std::array<boost::asio::const_buffer, 2> buffers = { {
std::array<boost::asio::const_buffer, 2> buffers = {
boost::asio::buffer(write_data, 32),
boost::asio::buffer(write_data) + 32 } };
boost::asio::buffer(write_data) + 32 };

s.reset();
bool called = false;
Expand Down Expand Up @@ -3220,9 +3220,9 @@ void test_4_arg_boost_array_buffers_async_write()
#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
boost::asio::io_context ioc;
test_stream s(ioc);
boost::array<boost::asio::const_buffer, 2> buffers = { {
boost::array<boost::asio::const_buffer, 2> buffers = {
boost::asio::buffer(write_data, 32),
boost::asio::buffer(write_data) + 32 } };
boost::asio::buffer(write_data) + 32 };

s.reset();
bool called = false;
Expand Down Expand Up @@ -3535,9 +3535,9 @@ void test_4_arg_std_array_buffers_async_write()
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
boost::asio::io_context ioc;
test_stream s(ioc);
std::array<boost::asio::const_buffer, 2> buffers = { {
std::array<boost::asio::const_buffer, 2> buffers = {
boost::asio::buffer(write_data, 32),
boost::asio::buffer(write_data) + 32 } };
boost::asio::buffer(write_data) + 32 };

s.reset();
bool called = false;
Expand Down
16 changes: 8 additions & 8 deletions test/write_at.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3156,9 +3156,9 @@ void test_4_arg_boost_array_buffers_async_write_at()
#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
boost::asio::io_context ioc;
test_random_access_device s(ioc);
boost::array<boost::asio::const_buffer, 2> buffers = { {
boost::array<boost::asio::const_buffer, 2> buffers = {
boost::asio::buffer(write_data, 32),
boost::asio::buffer(write_data) + 32 } };
boost::asio::buffer(write_data) + 32 };

s.reset();
bool called = false;
Expand Down Expand Up @@ -3258,9 +3258,9 @@ void test_4_arg_std_array_buffers_async_write_at()
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
boost::asio::io_context ioc;
test_random_access_device s(ioc);
std::array<boost::asio::const_buffer, 2> buffers = { {
std::array<boost::asio::const_buffer, 2> buffers = {
boost::asio::buffer(write_data, 32),
boost::asio::buffer(write_data) + 32 } };
boost::asio::buffer(write_data) + 32 };

s.reset();
bool called = false;
Expand Down Expand Up @@ -4860,9 +4860,9 @@ void test_5_arg_boost_array_buffers_async_write_at()
#if defined(BOOST_ASIO_HAS_BOOST_ARRAY)
boost::asio::io_context ioc;
test_random_access_device s(ioc);
boost::array<boost::asio::const_buffer, 2> buffers = { {
boost::array<boost::asio::const_buffer, 2> buffers = {
boost::asio::buffer(write_data, 32),
boost::asio::buffer(write_data) + 32 } };
boost::asio::buffer(write_data) + 32 };

s.reset();
bool called = false;
Expand Down Expand Up @@ -5505,9 +5505,9 @@ void test_5_arg_std_array_buffers_async_write_at()
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
boost::asio::io_context ioc;
test_random_access_device s(ioc);
std::array<boost::asio::const_buffer, 2> buffers = { {
std::array<boost::asio::const_buffer, 2> buffers = {
boost::asio::buffer(write_data, 32),
boost::asio::buffer(write_data) + 32 } };
boost::asio::buffer(write_data) + 32 };

s.reset();
bool called = false;
Expand Down

0 comments on commit a7d9701

Please sign in to comment.