【问题标题】:boost::xtime has no member named 'is_pos_infinity'boost::xtime 没有名为“is_pos_infinity”的成员
【发布时间】:2021-06-14 23:38:28
【问题描述】:

我的任务是移植一个遗留软件,客户决定在此过程中将 Boost 从 1.34 更新到 1.75。

不幸的是,我在编译时出现了这个问题:

/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);
      |                                       ^

这里发生了什么让 Boost 对自己不满意,我该如何解决?

【问题讨论】:

  • 这会很乏味,但是您应该仔细阅读每个发行说明并检查 boost::thread boost.org/users/history 中的每个 BREAKING CHANGE
  • @AlessandroTeruzzi 我认为这次将与第三方标头发生冲突。我会找到相关的帖子。
  • @sehe 它肯定是在使用 boost::xtime 而不是其他的 xtime;我在任何地方都没有看到任何关于模棱两可符号的信息,并且 xtime 也没有在其他任何地方定义。
  • 能分享一下预处理的源码吗
  • @sehe 我分享我的解决方案怎么样? stackoverflow.com/a/67928817/3597718

标签: c++ boost


【解决方案1】:

在我的特殊情况下,我能够找到根本原因并修复它。

我觉得就确定预期输入变量的类型应该是什么而言,最新的文档的布局很奇怪,但根据Boost v1.75 docm.timed_lock(t) 预计类型为boost::system_time,但仍然收到boost::xtime,这是它在Boost v1.34 中所期望的。

我们的源代码中计算提供给m.timed_lock(t) 的等待时间的某些地方提供了boost::xtime,我只需将它们更改为提供boost::system_time

【讨论】:

  • 您能否澄清“源中计算等待时间的某些地方”?您是在谈论 您的代码 还是 Boost 代码?在后一种情况下,您有一个正确的错误报告 :) 好吧,文档错误本身就是一个错误
  • @sehe 这是我正在处理的源代码,而不是 Boost 代码。我刚刚更新了答案以更好地反映这一点。
【解决方案2】:

我认为这是与我们之前在这里看到的第三方标头的冲突:

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

在这种情况下,重新排序包含的内容。如果这在您的情况下不起作用,您应该找出应该归咎于哪个库(通常是它用(宏)定义污染全局命名空间)。

然后您可以将缺陷报告给相应的维护人员。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-23
    相关资源
    最近更新 更多