首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >std::chrono的问题

std::chrono的问题
EN

Stack Overflow用户
提问于 2013-05-13 17:25:48
回答 1查看 28.3K关注 0票数 10

我在用chrono编译时遇到了问题,下面是代码:

Time.hh

代码语言:javascript
复制
#include        <chrono>

class           Time
{
protected:
  std::chrono::steady_clock::time_point _start_t;
  std::chrono::steady_clock::time_point _now;
  std::chrono::steady_clock::time_point _time;
public:
  Time();
  Time(const Time &other);
  Time          &operator=(const Time &other);
  ~Time();
public:
  void          start();
  double        getDurSec();
  double        getDurMilSec();
private:
  void          setNow();
};

编译错误:

代码语言:javascript
复制
g++  -W -Wall -Wextra -I./include -std=c++0x  -c -o src/Time/Time.o src/Time/Time.cpp
In file included from src/Time/Time.cpp:11:0:
./include/Time/Time.hh:21:3: error: ‘steady_clock’ in namespace ‘std::chrono’ does not     name a type
./include/Time/Time.hh:22:3: error: ‘steady_clock’ in namespace ‘std::chrono’ does not name a type
./include/Time/Time.hh:23:3: error: ‘steady_clock’ in namespace ‘std::chrono’ does not name a type
src/Time/Time.cpp: In member function ‘void Time::start()’:
src/Time/Time.cpp:34:2: error: ‘_time’ was not declared in this scope
src/Time/Time.cpp:34:23: error: ‘std::chrono::steady_clock’ has not been declared

等等。

如果您需要更多信息,请告诉我。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-13 17:49:12

您可能正在使用未实现std::chrono::steady_clock的4.7.0之前的g++版本。如果是这种情况,您有两种解决方案:

  • 将g++升级到4.7.0或更高版本。请使用旧的
票数 13
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16518705

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档