【问题标题】:boost timer usage question提升计时器使用问题
【发布时间】:2023-03-22 01:51:02
【问题描述】:

我有一个非常简单的问题,但我找不到答案。我想我在使用 boost timer.hpp 时遗漏了一些东西。这是我的代码,不幸的是,它给了我一条错误消息:

#include <boost/timer.hpp>

int main() {
    boost::timer t;
}

错误信息如下:

/usr/include/boost/timer.hpp: In member function ‘double boost::timer::elapsed_max() const’:
/usr/include/boost/timer.hpp:59: error: ‘numeric_limits’ is not a member of ‘std’
/usr/include/boost/timer.hpp:59: error: ‘::max’ has not been declared
/usr/include/boost/timer.hpp:59: error: expected primary-expression before ‘double’
/usr/include/boost/timer.hpp:59: error: expected `)' before ‘double’

使用的库是 boost 1.36 (SUSE 11.1)。

提前致谢!

【问题讨论】:

  • 附加信息:elapsed_max 是使用std::numeric_limits&lt;std::clock_t&gt;::max() 定义的,timer.hpp 标头通常间接包含&lt;limits&gt;(尽管如果使用BOOST_NO_LIMITS 宏可能会关闭)。我们可以到完整的编译行吗?

标签: c++ boost time


【解决方案1】:

应该没问题,顺便说一句,您确定您输入的是#include 而不是include

您应该不需要,但您也可以尝试包括:

#include <limits>

在增强之前包含似乎至少可以解决您的一些问题。

【讨论】:

    【解决方案2】:

    代码当然可以在 Windows 上使用 g++ 和 Boost 1.4.2 为我编译。你能给我们你的 g++ 编译器的版本吗?使用g++ --version。这看起来像是在定义 max 的情况之一,可能是一个宏。

    【讨论】:

    • 我使用:g++ (SUSE Linux) 4.3.2 [gcc-4_3-branch revision 141291] 和 boost 1.36
    • @stefita 您可能希望在您的系统上同时升级 GCC 和 Boost。
    猜你喜欢
    • 1970-01-01
    • 2010-09-11
    • 2021-02-02
    • 1970-01-01
    • 1970-01-01
    • 2020-04-10
    • 2019-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多