提升计时器使用问题

时间:2010-05-03 14:45:13

标签: c++ boost time

我有一个非常简单的问题,但我找不到答案。我想我在使用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)。

提前致谢!

2 个答案:

答案 0 :(得分:3)

应该没问题,在旁注上,您确定要输入#include而不是include吗?

您不应该这样做,但您也可以尝试包括:

#include <limits>

在提升之前,因为它似乎可能至少可以解决你的一些问题。

答案 1 :(得分:0)

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