|
| 1 | +diff --git a/rostime/include/ros/duration.h b/rostime/include/ros/duration.h |
| 2 | +index edd82dd..6a0e883 100644 |
| 3 | +--- a/rostime/include/ros/duration.h |
| 4 | ++++ b/rostime/include/ros/duration.h |
| 5 | +@@ -95,6 +95,7 @@ class DurationBase |
| 6 | + T& fromNSec(int64_t t); |
| 7 | + bool isZero() const; |
| 8 | + boost::posix_time::time_duration toBoost() const; |
| 9 | ++#ifndef _MSC_VER |
| 10 | + static const T MIN; //!< Minimum representable duration (negative) |
| 11 | + static const T MAX; //!< Maximum representable duration |
| 12 | + static const T ZERO; //!< Zero duration |
| 13 | +@@ -105,6 +106,7 @@ class DurationBase |
| 14 | + static const T MILLISECOND; //!< One millisecond duration |
| 15 | + static const T MICROSECOND; //!< One microsecond duration |
| 16 | + static const T NANOSECOND; //!< One nanosecond duration |
| 17 | ++#endif |
| 18 | + }; |
| 19 | + |
| 20 | + class Rate; |
| 21 | +@@ -136,6 +138,7 @@ class ROSTIME_DECL Duration : public DurationBase<Duration> |
| 22 | + |
| 23 | + extern ROSTIME_DECL const Duration DURATION_MAX; |
| 24 | + extern ROSTIME_DECL const Duration DURATION_MIN; |
| 25 | ++#ifndef _MSC_VER |
| 26 | + template<> const Duration DurationBase<Duration>::MAX; |
| 27 | + template<> const Duration DurationBase<Duration>::MIN; |
| 28 | + template<> const Duration DurationBase<Duration>::ZERO; |
| 29 | +@@ -146,6 +149,7 @@ template<> const Duration DurationBase<Duration>::SECOND; |
| 30 | + template<> const Duration DurationBase<Duration>::MILLISECOND; |
| 31 | + template<> const Duration DurationBase<Duration>::MICROSECOND; |
| 32 | + template<> const Duration DurationBase<Duration>::NANOSECOND; |
| 33 | ++#endif |
| 34 | + |
| 35 | + /** |
| 36 | + * \brief Duration representation for use with the WallTime class. |
| 37 | +@@ -172,6 +176,7 @@ class ROSTIME_DECL WallDuration : public DurationBase<WallDuration> |
| 38 | + bool sleep() const; |
| 39 | + }; |
| 40 | + |
| 41 | ++#ifndef _MSC_VER |
| 42 | + template<> const WallDuration DurationBase<WallDuration>::MAX; |
| 43 | + template<> const WallDuration DurationBase<WallDuration>::MIN; |
| 44 | + template<> const WallDuration DurationBase<WallDuration>::ZERO; |
| 45 | +@@ -182,6 +187,7 @@ template<> const WallDuration DurationBase<WallDuration>::SECOND; |
| 46 | + template<> const WallDuration DurationBase<WallDuration>::MILLISECOND; |
| 47 | + template<> const WallDuration DurationBase<WallDuration>::MICROSECOND; |
| 48 | + template<> const WallDuration DurationBase<WallDuration>::NANOSECOND; |
| 49 | ++#endif |
| 50 | + |
| 51 | + ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const Duration &rhs); |
| 52 | + ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const WallDuration &rhs); |
| 53 | +diff --git a/rostime/include/ros/time.h b/rostime/include/ros/time.h |
| 54 | +index c4ff2fe..79f2eae 100644 |
| 55 | +--- a/rostime/include/ros/time.h |
| 56 | ++++ b/rostime/include/ros/time.h |
| 57 | +@@ -160,10 +160,12 @@ namespace ros |
| 58 | + inline bool is_zero() const { return isZero(); } |
| 59 | + boost::posix_time::ptime toBoost() const; |
| 60 | + |
| 61 | ++#ifndef _MSC_VER |
| 62 | + static const T MIN; //!< Minimum representable time |
| 63 | + static const T MAX; //!< Maximum representable time |
| 64 | + static const T ZERO; //!< Zero (invalid) time |
| 65 | + static const T UNINITIALIZED; //!< Uninitialized time |
| 66 | ++#endif |
| 67 | + }; |
| 68 | + |
| 69 | + /** |
| 70 | +@@ -221,10 +223,12 @@ namespace ros |
| 71 | + |
| 72 | + extern ROSTIME_DECL const Time TIME_MAX; |
| 73 | + extern ROSTIME_DECL const Time TIME_MIN; |
| 74 | ++#ifndef _MSC_VER |
| 75 | + template<> const Time TimeBase<Time, Duration>::MAX; |
| 76 | + template<> const Time TimeBase<Time, Duration>::MIN; |
| 77 | + template<> const Time TimeBase<Time, Duration>::ZERO; |
| 78 | + template<> const Time TimeBase<Time, Duration>::UNINITIALIZED; |
| 79 | ++#endif |
| 80 | + |
| 81 | + /** |
| 82 | + * \brief Time representation. Always wall-clock time. |
| 83 | +@@ -258,11 +262,13 @@ namespace ros |
| 84 | + static bool isSystemTime() { return true; } |
| 85 | + }; |
| 86 | + |
| 87 | ++#ifndef _MSC_VER |
| 88 | + template<> const WallTime TimeBase<WallTime, WallDuration>::MAX; |
| 89 | + template<> const WallTime TimeBase<WallTime, WallDuration>::MIN; |
| 90 | + template<> const WallTime TimeBase<WallTime, WallDuration>::ZERO; |
| 91 | + template<> const WallTime TimeBase<WallTime, WallDuration>::UNINITIALIZED; |
| 92 | +- |
| 93 | ++#endif |
| 94 | ++ |
| 95 | + /** |
| 96 | + * \brief Time representation. Always steady-clock time. |
| 97 | + * |
| 98 | +@@ -297,10 +303,12 @@ namespace ros |
| 99 | + static bool isSystemTime() { return true; } |
| 100 | + }; |
| 101 | + |
| 102 | ++#ifndef _MSC_VER |
| 103 | + template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::MAX; |
| 104 | + template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::MIN; |
| 105 | + template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::ZERO; |
| 106 | + template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::UNINITIALIZED; |
| 107 | ++#endif |
| 108 | + |
| 109 | + ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const Time &rhs); |
| 110 | + ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const WallTime &rhs); |
| 111 | +diff --git a/rostime/src/time.cpp b/rostime/src/time.cpp |
| 112 | +index 7edb3cc..0bca1c4 100644 |
| 113 | +--- a/rostime/src/time.cpp |
| 114 | ++++ b/rostime/src/time.cpp |
| 115 | +@@ -83,6 +83,7 @@ namespace ros |
| 116 | + const Duration DURATION_MAX(std::numeric_limits<int32_t>::max(), 999999999); |
| 117 | + const Duration DURATION_MIN(std::numeric_limits<int32_t>::min(), 0); |
| 118 | + |
| 119 | ++#ifndef _MSC_VER |
| 120 | + template<> const Duration DurationBase<Duration>::MAX = DURATION_MAX; |
| 121 | + template<> const Duration DurationBase<Duration>::MIN = DURATION_MIN; |
| 122 | + template<> const Duration DurationBase<Duration>::ZERO = Duration(0, 0); |
| 123 | +@@ -104,10 +105,12 @@ namespace ros |
| 124 | + template<> const WallDuration DurationBase<WallDuration>::MILLISECOND = WallDuration(Duration::MILLISECOND.sec, Duration::MILLISECOND.nsec); |
| 125 | + template<> const WallDuration DurationBase<WallDuration>::MICROSECOND = WallDuration(Duration::MICROSECOND.sec, Duration::MICROSECOND.nsec); |
| 126 | + template<> const WallDuration DurationBase<WallDuration>::NANOSECOND = WallDuration(Duration::NANOSECOND.sec, Duration::NANOSECOND.nsec); |
| 127 | ++#endif |
| 128 | + |
| 129 | + const Time TIME_MAX(std::numeric_limits<uint32_t>::max(), 999999999); |
| 130 | + const Time TIME_MIN(0, 1); |
| 131 | + |
| 132 | ++#ifndef _MSC_VER |
| 133 | + template<> const Time TimeBase<Time, Duration>::MAX = TIME_MAX; |
| 134 | + template<> const Time TimeBase<Time, Duration>::MIN = TIME_MIN; |
| 135 | + template<> const Time TimeBase<Time, Duration>::ZERO = Time(0, 0); |
| 136 | +@@ -122,6 +125,7 @@ namespace ros |
| 137 | + template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::MIN = SteadyTime(Time::MIN.sec, Time::MIN.nsec); |
| 138 | + template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::ZERO = SteadyTime(Time::ZERO.sec, Time::ZERO.nsec); |
| 139 | + template<> const SteadyTime TimeBase<SteadyTime, WallDuration>::UNINITIALIZED = SteadyTime(Time::UNINITIALIZED.sec, Time::UNINITIALIZED.nsec); |
| 140 | ++#endif |
| 141 | + |
| 142 | + // This is declared here because it's set from the Time class but read from |
| 143 | + // the Duration class, and need not be exported to users of either. |
| 144 | +diff --git a/rostime/test/time.cpp b/rostime/test/time.cpp |
| 145 | +index 96ef161..e52a960 100644 |
| 146 | +--- a/rostime/test/time.cpp |
| 147 | ++++ b/rostime/test/time.cpp |
| 148 | +@@ -370,6 +370,7 @@ TEST(Time, OperatorPlusExceptions) |
| 149 | + EXPECT_THROW(t5 + d3, std::runtime_error); |
| 150 | + } |
| 151 | + |
| 152 | ++#ifndef _MSC_VER |
| 153 | + TEST(Time, Constants) |
| 154 | + { |
| 155 | + EXPECT_EQ(Time::MAX.sec, static_cast<uint32_t>(-1)); |
| 156 | +@@ -399,6 +400,7 @@ TEST(Time, Constants) |
| 157 | + EXPECT_EQ(SteadyTime::UNINITIALIZED.sec, 0); |
| 158 | + EXPECT_EQ(SteadyTime::UNINITIALIZED.nsec, 0); |
| 159 | + } |
| 160 | ++#endif |
| 161 | + |
| 162 | + /************************************* Duration Tests *****************/ |
| 163 | + |
| 164 | +@@ -588,6 +590,7 @@ TEST(Duration, sleepWithSignal) |
| 165 | + ASSERT_TRUE(rc); |
| 166 | + } |
| 167 | + |
| 168 | ++#ifndef _MSC_VER |
| 169 | + TEST(Duration, Constants) |
| 170 | + { |
| 171 | + EXPECT_EQ(Duration::MAX.sec, std::numeric_limits<int32_t>::max()); |
| 172 | +@@ -632,6 +635,7 @@ TEST(Duration, Constants) |
| 173 | + EXPECT_EQ(WallDuration::DAY.sec, 60 * 60 * 24); |
| 174 | + EXPECT_EQ(WallDuration::DAY.nsec, 0); |
| 175 | + } |
| 176 | ++#endif |
| 177 | + |
| 178 | + TEST(Rate, constructFromDuration){ |
| 179 | + Duration d(4, 0); |
0 commit comments