Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build issues when windows.h is included before Fast DDS headers [10521] (backport #1746) #2383

Merged
merged 1 commit into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ struct RTPSParticipantAllocationAttributes
ResourceLimitedContainerConfig total_endpoints(
const ResourceLimitedContainerConfig& endpoints) const
{
constexpr size_t max = std::numeric_limits<size_t>::max();
constexpr size_t max = (std::numeric_limits<size_t>::max)();
size_t initial;
size_t maximum;
size_t increment;

initial = participants.initial * endpoints.initial;
maximum = (participants.maximum == max || endpoints.maximum == max)
? max : participants.maximum * endpoints.maximum;
increment = std::max(participants.increment, endpoints.increment);
increment = (std::max)(participants.increment, endpoints.increment);

return { initial, maximum, increment };
}
Expand Down
28 changes: 7 additions & 21 deletions include/fastdds/rtps/common/CacheChange.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,22 @@
#ifndef _FASTDDS_RTPS_CACHECHANGE_H_
#define _FASTDDS_RTPS_CACHECHANGE_H_

#include <fastdds/rtps/common/Types.h>
#include <fastdds/rtps/common/WriteParams.h>
#include <cassert>

#include <fastdds/rtps/common/ChangeKind_t.hpp>
#include <fastdds/rtps/common/FragmentNumber.h>
#include <fastdds/rtps/common/InstanceHandle.h>
#include <fastdds/rtps/common/SerializedPayload.h>
#include <fastdds/rtps/common/Time_t.h>
#include <fastdds/rtps/common/InstanceHandle.h>
#include <fastdds/rtps/common/FragmentNumber.h>

#include <cassert>
#include <fastdds/rtps/common/Types.h>
#include <fastdds/rtps/common/WriteParams.h>

#include <fastdds/rtps/history/IPayloadPool.h>

namespace eprosima {
namespace fastrtps {
namespace rtps {


/**
* @enum ChangeKind_t, different types of CacheChange_t.
* @ingroup COMMON_MODULE
*/
enum RTPS_DllAPI ChangeKind_t
{
ALIVE, //!< ALIVE
NOT_ALIVE_DISPOSED, //!< NOT_ALIVE_DISPOSED
NOT_ALIVE_UNREGISTERED, //!< NOT_ALIVE_UNREGISTERED
NOT_ALIVE_DISPOSED_UNREGISTERED //!< NOT_ALIVE_DISPOSED_UNREGISTERED
};

/**
* Structure CacheChange_t, contains information on a specific CacheChange.
* @ingroup COMMON_MODULE
Expand Down Expand Up @@ -406,6 +394,4 @@ struct RTPS_DllAPI CacheChange_t
} // namespace fastrtps
} // namespace eprosima

#include <fastdds/rtps/writer/ChangeForReader.h>

#endif /* _FASTDDS_RTPS_CACHECHANGE_H_ */
44 changes: 44 additions & 0 deletions include/fastdds/rtps/common/ChangeKind_t.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2021 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file ChangeKind_t.hpp
*/

#ifndef _FASTDDS_RTPS_COMMON_CHANGEKINDT_HPP_
#define _FASTDDS_RTPS_COMMON_CHANGEKINDT_HPP_

#include <fastrtps/fastrtps_dll.h>

namespace eprosima {
namespace fastrtps {
namespace rtps {

/**
* @enum ChangeKind_t, different types of CacheChange_t.
* @ingroup COMMON_MODULE
*/
enum RTPS_DllAPI ChangeKind_t
{
ALIVE, //!< ALIVE
NOT_ALIVE_DISPOSED, //!< NOT_ALIVE_DISPOSED
NOT_ALIVE_UNREGISTERED, //!< NOT_ALIVE_UNREGISTERED
NOT_ALIVE_DISPOSED_UNREGISTERED //!< NOT_ALIVE_DISPOSED_UNREGISTERED
};

} // namespace rtps
} // namespace fastrtps
} // namespace eprosima

#endif /* _FASTDDS_RTPS_COMMON_CHANGEKINDT_HPP_ */
2 changes: 1 addition & 1 deletion include/fastdds/rtps/common/LocatorSelector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class LocatorSelector
Position index_pos)
: locator_selector_(locator_selector)
{
current_ = {std::numeric_limits<size_t>::max(), 0, true, nullptr};
current_ = {(std::numeric_limits<size_t>::max)(), 0, true, nullptr};

if (index_pos == Position::Begin)
{
Expand Down
9 changes: 5 additions & 4 deletions include/fastrtps/subscriber/SampleInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

#include <cstdint>

#include <fastrtps/fastrtps_dll.h>

#include <fastdds/rtps/common/Time_t.h>
#include <fastdds/rtps/common/ChangeKind_t.hpp>
#include <fastdds/rtps/common/InstanceHandle.h>
#include <fastdds/rtps/common/CacheChange.h>
#include <fastdds/rtps/common/SampleIdentity.h>
#include <fastdds/rtps/common/Time_t.h>

#include <fastrtps/fastrtps_dll.h>

namespace eprosima {
namespace fastrtps {
Expand Down
30 changes: 30 additions & 0 deletions include/fastrtps/types/AnnotationParameterValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@
#ifndef _ANNOTATIONPARAMETERVALUE_H_
#define _ANNOTATIONPARAMETERVALUE_H_

#if _MSC_VER

#if defined(max)
#pragma push_macro("max")
#undef max
#define FASTDDS_RESTORE_MAX
#endif // defined(max)

#if defined(min)
#pragma push_macro("min")
#undef min
#define FASTDDS_RESTORE_MIN
#endif // defined(min)

#endif // if _MSC_VER

#include <fastrtps/types/TypesBase.h>
#include <fastrtps/types/TypeIdentifier.h>
#include <fastrtps/utils/string_convert.hpp>
Expand Down Expand Up @@ -1349,4 +1365,18 @@ class AppliedBuiltinMemberAnnotations
} // namespace fastrtps
} // namespace eprosima

#if _MSC_VER

#if defined(FASTDDS_RESTORE_MIN)
#pragma pop_macro("min")
#undef FASTDDS_RESTORE_MIN
#endif // defined(FASTDDS_RESTORE_MIN)

#if defined(FASTDDS_RESTORE_MAX)
#pragma pop_macro("max")
#undef FASTDDS_RESTORE_MAX
#endif // defined(FASTDDS_RESTORE_MAX)

#endif // if _MSC_VER

#endif // _ANNOTATIONPARAMETERVALUE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct ResourceLimitedContainerConfig
{

ResourceLimitedContainerConfig(
size_t ini = 0,
size_t max = std::numeric_limits<size_t>::max(),
size_t ini = 0,
size_t max = (std::numeric_limits<size_t>::max)(),
size_t inc = 1u)
: initial(ini)
, maximum(max)
Expand All @@ -46,7 +46,7 @@ struct ResourceLimitedContainerConfig
//! Number of elements to be preallocated in the collection.
size_t initial = 0;
//! Maximum number of elements allowed in the collection.
size_t maximum = std::numeric_limits<size_t>::max();
size_t maximum = (std::numeric_limits<size_t>::max)();
//! Number of items to add when capacity limit is reached.
size_t increment = 1u;

Expand All @@ -55,7 +55,8 @@ struct ResourceLimitedContainerConfig
* @param size Number of elements to allocate.
* @return Resource limits configuration.
*/
inline static ResourceLimitedContainerConfig fixed_size_configuration(size_t size)
inline static ResourceLimitedContainerConfig fixed_size_configuration(
size_t size)
{
return ResourceLimitedContainerConfig(size, size, 0u);
}
Expand All @@ -65,14 +66,16 @@ struct ResourceLimitedContainerConfig
* @param increment Number of new elements to allocate when increasing the capacity of the collection.
* @return Resource limits configuration.
*/
inline static ResourceLimitedContainerConfig dynamic_allocation_configuration(size_t increment = 1u)
inline static ResourceLimitedContainerConfig dynamic_allocation_configuration(
size_t increment = 1u)
{
return ResourceLimitedContainerConfig(0u, std::numeric_limits<size_t>::max(), increment ? increment : 1u);
return ResourceLimitedContainerConfig(0u, (std::numeric_limits<size_t>::max)(), increment ? increment : 1u);
}

};

inline bool operator == (
const ResourceLimitedContainerConfig& lhs,
const ResourceLimitedContainerConfig& lhs,
const ResourceLimitedContainerConfig& rhs)
{
return
Expand Down
10 changes: 5 additions & 5 deletions include/fastrtps/utils/collections/ResourceLimitedVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class ResourceLimitedVector
InputIterator last)
{
size_type n = static_cast<size_type>(std::distance(first, last));
n = std::min(n, configuration_.maximum);
n = (std::min)(n, configuration_.maximum);
InputIterator value = first;
std::advance(value, n);
collection_.assign(first, value);
Expand All @@ -268,7 +268,7 @@ class ResourceLimitedVector
size_type n,
const value_type& val)
{
n = std::min(n, configuration_.maximum);
n = (std::min)(n, configuration_.maximum);
collection_.assign(n, val);
}

Expand All @@ -286,7 +286,7 @@ class ResourceLimitedVector
void assign(
std::initializer_list<value_type> il)
{
size_type n = std::min(il.size(), configuration_.maximum);
size_type n = (std::min)(il.size(), configuration_.maximum);
collection_.assign(il.begin(), il.begin() + n);
}

Expand Down Expand Up @@ -416,7 +416,7 @@ class ResourceLimitedVector

size_type max_size() const noexcept
{
return std::min(configuration_.maximum, collection_.max_size());
return (std::min)(configuration_.maximum, collection_.max_size());
}

void clear()
Expand Down Expand Up @@ -490,7 +490,7 @@ class ResourceLimitedVector
// increase collection capacity
assert(configuration_.increment > 0);
cap += configuration_.increment;
cap = std::min(cap, configuration_.maximum);
cap = (std::min)(cap, configuration_.maximum);
collection_.reserve(cap);
}
else
Expand Down
27 changes: 27 additions & 0 deletions include/fastrtps/utils/fixed_size_bitmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@

#if _MSC_VER
#include <intrin.h>

#if defined(max)
#pragma push_macro("max")
#undef max
#define FASTDDS_RESTORE_MAX
#endif // defined(max)

#if defined(min)
#pragma push_macro("min")
#undef min
#define FASTDDS_RESTORE_MIN
#endif // defined(min)

#endif // if _MSC_VER

#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
Expand Down Expand Up @@ -574,4 +587,18 @@ class BitmapRange

#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC

#if _MSC_VER

#if defined(FASTDDS_RESTORE_MIN)
#pragma pop_macro("min")
#undef FASTDDS_RESTORE_MIN
#endif // defined(FASTDDS_RESTORE_MIN)

#if defined(FASTDDS_RESTORE_MAX)
#pragma pop_macro("max")
#undef FASTDDS_RESTORE_MAX
#endif // defined(FASTDDS_RESTORE_MAX)

#endif // if _MSC_VER

#endif // FASTRTPS_UTILS_FIXED_SIZE_BITMAP_HPP_
18 changes: 11 additions & 7 deletions test/blackbox/api/dds-pim/PubSubReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
#ifndef _TEST_BLACKBOX_PUBSUBREADER_HPP_
#define _TEST_BLACKBOX_PUBSUBREADER_HPP_

#include <string>
#include <list>
#include <atomic>
#include <condition_variable>
#include <asio.hpp>
#include <gtest/gtest.h>

#if _MSC_VER
#include <Windows.h>
#endif // _MSC_VER

#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantListener.hpp>
Expand All @@ -37,13 +48,6 @@
#include <fastrtps/utils/IPLocator.h>
#include <fastrtps/transport/UDPv4TransportDescriptor.h>

#include <string>
#include <list>
#include <atomic>
#include <condition_variable>
#include <asio.hpp>
#include <gtest/gtest.h>

using DomainParticipantFactory = eprosima::fastdds::dds::DomainParticipantFactory;
using eprosima::fastrtps::rtps::IPLocator;
using eprosima::fastrtps::rtps::UDPv4TransportDescriptor;
Expand Down
19 changes: 12 additions & 7 deletions test/blackbox/api/dds-pim/PubSubWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
#ifndef _TEST_BLACKBOX_PUBSUBWRITER_HPP_
#define _TEST_BLACKBOX_PUBSUBWRITER_HPP_

#include <string>
#include <list>
#include <map>
#include <condition_variable>
#include <asio.hpp>
#include <gtest/gtest.h>
#include <thread>

#if _MSC_VER
#include <Windows.h>
#endif // _MSC_VER

#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/domain/DomainParticipant.hpp>
#include <fastdds/dds/domain/DomainParticipantListener.hpp>
Expand All @@ -34,13 +46,6 @@
#include <fastrtps/xmlparser/XMLTree.h>
#include <fastrtps/utils/IPLocator.h>
#include <fastrtps/transport/UDPv4TransportDescriptor.h>
#include <string>
#include <list>
#include <map>
#include <condition_variable>
#include <asio.hpp>
#include <gtest/gtest.h>
#include <thread>

using DomainParticipantFactory = eprosima::fastdds::dds::DomainParticipantFactory;
using eprosima::fastrtps::rtps::IPLocator;
Expand Down