From 7a280f40c6310dbc877b34e6d58cb28f37ef26b9 Mon Sep 17 00:00:00 2001 From: Johnson Shih Date: Thu, 19 Jul 2018 14:51:38 -0700 Subject: [PATCH 1/2] Add ROSTIME_DECL storage-class attribute --- rostime/include/ros/duration.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rostime/include/ros/duration.h b/rostime/include/ros/duration.h index 8485fd8f..e88e61e1 100644 --- a/rostime/include/ros/duration.h +++ b/rostime/include/ros/duration.h @@ -153,8 +153,8 @@ class ROSTIME_DECL WallDuration : public DurationBase bool sleep() const; }; -std::ostream &operator <<(std::ostream &os, const Duration &rhs); -std::ostream &operator <<(std::ostream &os, const WallDuration &rhs); +ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const Duration &rhs); +ROSTIME_DECL std::ostream &operator <<(std::ostream &os, const WallDuration &rhs); } From 42bc17d80e0d03c92ea320abf3fa3611714c1648 Mon Sep 17 00:00:00 2001 From: Johnson Shih Date: Mon, 30 Jul 2018 17:51:33 -0700 Subject: [PATCH 2/2] Fix build issue on Windows, signal/alarm not available on Windows --- rostime/test/time.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rostime/test/time.cpp b/rostime/test/time.cpp index f9e19ec1..93ffd539 100644 --- a/rostime/test/time.cpp +++ b/rostime/test/time.cpp @@ -32,7 +32,9 @@ #include #include #include +#ifndef _WIN32 #include +#endif #include @@ -45,9 +47,13 @@ double epsilon = 1e-9; void seed_rand() { //Seed random number generator with current microseond count +#ifndef _WIN32 timeval temp_time_struct; gettimeofday(&temp_time_struct,NULL); srand(temp_time_struct.tv_usec); +#else + srand(time(nullptr)); +#endif }; void generate_rand_times(uint32_t range, uint64_t runs, std::vector& values1, std::vector& values2) @@ -509,8 +515,11 @@ void alarmHandler(int sig) TEST(Duration, sleepWithSignal) { +#ifndef _WIN32 signal(SIGALRM, alarmHandler); alarm(1); +#endif + Time start = Time::now(); Duration d(2.0); bool rc = d.sleep();