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

Library is potentially incompatible with Boost 1.8 #34

Open
TaqiHamoda opened this issue Jan 1, 2023 · 1 comment
Open

Library is potentially incompatible with Boost 1.8 #34

TaqiHamoda opened this issue Jan 1, 2023 · 1 comment

Comments

@TaqiHamoda
Copy link

I am trying to build the library but I get the following compilation errors:

/home/.../shared_memory/src/locked_condition_variable.cpp: In member function 'bool shared_memory::LockedConditionVariable::timed_wait(long int)':
/home/.../shared_memory/src/locked_condition_variable.cpp:64:16: error: 'boost::posix_time' has not been declared
   64 |         boost::posix_time::ptime current_time =
      |                ^~~~~~~~~~
/home/.../shared_memory/src/locked_condition_variable.cpp:66:16: error: 'boost::posix_time' has not been declared
   66 |         boost::posix_time::time_duration waiting_time =
      |                ^~~~~~~~~~
/home/.../shared_memory/src/locked_condition_variable.cpp:70:48: error: 'current_time' was not declared in this scope
   70 |                                                current_time + waiting_time);
      |                                                ^~~~~~~~~~~~
/home/.../shared_memory/src/locked_condition_variable.cpp:70:63: error: 'waiting_time' was not declared in this scope
   70 |                                                current_time + waiting_time);
      |                                                               ^~~~~~~~~~~~
/home/.../shared_memory/src/locked_condition_variable.cpp:60:47: warning: unused parameter 'wait_nano_seconds' [-Wunused-parameter]
   60 | bool LockedConditionVariable::timed_wait(long wait_nano_seconds)
      |                                          ~~~~~^~~~~~~~~~~~~~~~~

These issues were resolved when I added the #include <boost/date_time/posix_time/posix_time.hpp> header to shared_memory.hpp. There are other compilation issues that are also resolved by adding the appropriate headers.

@TaqiHamoda
Copy link
Author

TaqiHamoda commented May 19, 2023

It has been a while and there is no reply. I tried doing a pull request but I got an unauthorized error. Since there is no support, I will post a diff of my changes in case anyone faces the same issue I did.

diff --git a/include/shared_memory/shared_memory.hpp b/include/shared_memory/shared_memory.hpp
index 0738b93..0c080ff 100644
--- a/include/shared_memory/shared_memory.hpp
+++ b/include/shared_memory/shared_memory.hpp
@@ -26,6 +26,7 @@
 
 #include <Eigen/Dense>
 
+#include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/interprocess/allocators/allocator.hpp>
 #include <boost/interprocess/containers/deque.hpp>
 #include <boost/interprocess/containers/string.hpp>
diff --git a/src/condition_variable.cpp b/src/condition_variable.cpp
index 54bdbb8..b84fb42 100644
--- a/src/condition_variable.cpp
+++ b/src/condition_variable.cpp
@@ -48,7 +48,7 @@ void ConditionVariable::wait(Lock &lock)
 bool ConditionVariable::timed_wait(Lock &lock, long wait_nano_seconds)
 {
     boost::posix_time::ptime current_time =
-        boost::interprocess::microsec_clock::universal_time();
+        boost::posix_time::microsec_clock::universal_time();
     boost::posix_time::time_duration waiting_time =
         boost::posix_time::microseconds(
             static_cast<long>(static_cast<double>(wait_nano_seconds) * 0.001));
diff --git a/src/locked_condition_variable.cpp b/src/locked_condition_variable.cpp
index d3fafb1..17221f3 100644
--- a/src/locked_condition_variable.cpp
+++ b/src/locked_condition_variable.cpp
@@ -62,7 +62,7 @@ bool LockedConditionVariable::timed_wait(long wait_nano_seconds)
     if (lock_)
     {
         boost::posix_time::ptime current_time =
-            boost::interprocess::microsec_clock::universal_time();
+            boost::posix_time::microsec_clock::universal_time();
         boost::posix_time::time_duration waiting_time =
             boost::posix_time::microseconds(static_cast<long>(
                 static_cast<double>(wait_nano_seconds) * 0.001));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant