简体   繁体   中英

boost::xtime has no member named 'is_pos_infinity'

I've been tasked with porting a piece of legacy software and the client has decided they want to update Boost from 1.34 to 1.75 in the process.

Unfortunately, I'm having this issue show up when compiling:

/usr/include/boost/thread/pthread/recursive_mutex.hpp: In instantiation of ‘bool boost::recursive_timed_mutex::timed_lock(const TimeDuration&) [with TimeDuration = boost::xtime]’:
/usr/include/boost/thread/lock_types.hpp:403:30:   required from ‘bool boost::unique_lock<Mutex>::timed_lock(const boost::xtime&) [with Mutex = boost::recursive_timed_mutex]’
/usr/include/boost/thread/lock_types.hpp:146:17:   required from ‘boost::unique_lock<Mutex>::unique_lock(Mutex&, const TimeDuration&) [with TimeDuration = boost::xtime; Mutex = boost::recursive_timed_mutex]’
{project source file}.hpp:206:118:   required from here
/usr/include/boost/thread/pthread/recursive_mutex.hpp:244:31: error: ‘const struct boost::xtime’ has no member named ‘is_pos_infinity’
  244 |             if (relative_time.is_pos_infinity())
      |                 ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/usr/include/boost/thread/pthread/recursive_mutex.hpp:249:31: error: ‘const struct boost::xtime’ has no member named ‘is_special’
  249 |             if (relative_time.is_special())
      |                 ~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/boost/thread/pthread/recursive_mutex.hpp:253:39: error: no matching function for call to ‘boost::detail::platform_duration::platform_duration(const boost::xtime&)’
  253 |             detail::platform_duration d(relative_time);
      |                                       ^

What could be going on here that's making Boost unhappy with itself, and how might I fix it?

In my particular case, I was able to find the root cause and fix it.

I feel like the latest doc is weirdly laid out as far as determining what the expected input-variable's type should be is concerned, but according to the Boost v1.75 doc , m.timed_lock(t) expects a type of boost::system_time , yet was still being fed a boost::xtime , which was what it expected back in Boost v1.34 .

Some places in our source code that calculated the wait time fed to m.timed_lock(t) provided a boost::xtime , and I just needed to change them to provide a boost::system_time instead.

I think this is a conflict with third-party headers which we've seen before here:

"xtime: ambiguous symbol" error, when including <boost/asio.hpp>

In that case reordering the includes worked out. If that doesn't work in your situation, you should work out which library is to blame (usually its the one that contaminates global namespace with (macro) definitions).

And then you can report the defect to the respective maintainers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM