From 9344ae38fe0cd4b2b8f9e7ad4ef7511116c90de2 Mon Sep 17 00:00:00 2001 From: cferreiragonz Date: Tue, 12 Mar 2024 11:12:18 +0100 Subject: [PATCH] Refs #20352: Fix Windows build Signed-off-by: cferreiragonz --- .../fastdds/rtps/network/NetworkBuffer.hpp | 19 ++++++++++--------- .../rtps/transport/TransportInterface.h | 1 - src/cpp/rtps/transport/ChannelResource.h | 1 - src/cpp/rtps/transport/TCPChannelResource.h | 2 +- .../rtps/transport/UDPTransportInterface.cpp | 6 ++++++ .../rtps/transport/test_UDPv4Transport.cpp | 1 + .../fastdds/rtps/reader/StatefulReader.h | 3 +++ 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/fastdds/rtps/network/NetworkBuffer.hpp b/include/fastdds/rtps/network/NetworkBuffer.hpp index f9f49db3e65..febca888604 100644 --- a/include/fastdds/rtps/network/NetworkBuffer.hpp +++ b/include/fastdds/rtps/network/NetworkBuffer.hpp @@ -19,9 +19,12 @@ #ifndef _FASTDDS_RTPS_NETWORK_NETWORKBUFFER_HPP #define _FASTDDS_RTPS_NETWORK_NETWORKBUFFER_HPP -#include // uint32_t -#include // size_t -#include +#include + +namespace asio { +// Forward declaration of asio::const_buffer +class const_buffer; +} // namespace asio namespace eprosima { namespace fastdds { @@ -36,11 +39,11 @@ struct NetworkBuffer final //! Pointer to the buffer where the data is stored. const void* buffer; //! Number of bytes to use starting at @c buffer. - size_t size; + uint32_t size; NetworkBuffer( const void* ptr, - size_t s) + uint32_t s) : buffer(ptr) , size(s) { @@ -54,7 +57,7 @@ struct NetworkBuffer final NetworkBuffer( const fastrtps::rtps::octet* ptr, - size_t s) + uint32_t s) : buffer(ptr) , size(s) { @@ -79,9 +82,7 @@ struct NetworkBuffer final } //! Conversion operator to asio::const_buffer. - operator asio::const_buffer() const { - return asio::const_buffer(buffer, size); - } + operator asio::const_buffer() const; }; } // namespace rtps diff --git a/include/fastdds/rtps/transport/TransportInterface.h b/include/fastdds/rtps/transport/TransportInterface.h index f5ae290135e..b016492476b 100644 --- a/include/fastdds/rtps/transport/TransportInterface.h +++ b/include/fastdds/rtps/transport/TransportInterface.h @@ -30,7 +30,6 @@ #include #include #include -#include namespace eprosima { namespace fastdds { diff --git a/src/cpp/rtps/transport/ChannelResource.h b/src/cpp/rtps/transport/ChannelResource.h index 780963104ec..58a25b2b764 100644 --- a/src/cpp/rtps/transport/ChannelResource.h +++ b/src/cpp/rtps/transport/ChannelResource.h @@ -19,7 +19,6 @@ #include #include -#include #include diff --git a/src/cpp/rtps/transport/TCPChannelResource.h b/src/cpp/rtps/transport/TCPChannelResource.h index 673fd4956e3..8473472fcea 100644 --- a/src/cpp/rtps/transport/TCPChannelResource.h +++ b/src/cpp/rtps/transport/TCPChannelResource.h @@ -152,7 +152,7 @@ class TCPChannelResource : public ChannelResource const fastrtps::rtps::octet* header, size_t header_size, const fastrtps::rtps::octet* data, - size_t data_size, + uint32_t data_size, asio::error_code& ec) { NetworkBuffer buffers(data, data_size); diff --git a/src/cpp/rtps/transport/UDPTransportInterface.cpp b/src/cpp/rtps/transport/UDPTransportInterface.cpp index 719fd52bc43..664f7037670 100644 --- a/src/cpp/rtps/transport/UDPTransportInterface.cpp +++ b/src/cpp/rtps/transport/UDPTransportInterface.cpp @@ -576,6 +576,12 @@ bool UDPTransportInterface::send( return success; } +//! NetworkBuffer conversion operator to asio::const_buffer. +NetworkBuffer::operator asio::const_buffer() const +{ + return asio::const_buffer(buffer, size); +} + /** * Invalidate all selector entries containing certain multicast locator. * diff --git a/src/cpp/rtps/transport/test_UDPv4Transport.cpp b/src/cpp/rtps/transport/test_UDPv4Transport.cpp index ca7413446ce..055b4e9b9cc 100644 --- a/src/cpp/rtps/transport/test_UDPv4Transport.cpp +++ b/src/cpp/rtps/transport/test_UDPv4Transport.cpp @@ -496,6 +496,7 @@ bool test_UDPv4Transport::log_drop( const std::list& buffers, uint32_t size) { + static_cast(size); if (test_UDPv4Transport_DropLog.size() < test_UDPv4Transport_DropLogLength) { vector message; diff --git a/test/mock/rtps/StatefulReader/fastdds/rtps/reader/StatefulReader.h b/test/mock/rtps/StatefulReader/fastdds/rtps/reader/StatefulReader.h index c092cb87360..5a710433da3 100644 --- a/test/mock/rtps/StatefulReader/fastdds/rtps/reader/StatefulReader.h +++ b/test/mock/rtps/StatefulReader/fastdds/rtps/reader/StatefulReader.h @@ -15,10 +15,13 @@ #ifndef _FASTDDS_RTPS_READER_STATEFULREADER_H_ #define _FASTDDS_RTPS_READER_STATEFULREADER_H_ +#include + #include #include #include #include +#include namespace eprosima { namespace fastrtps {