2013-05-13 12 views
6

Mam problemy z kompilowania z chrono, oto kod:Problemy z std :: Chrono

Time.hh

#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(); 
}; 

błąd kompilacji:

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 

Etc ...

Powiedz, czy potrzebujesz więcej informacji.

+0

Prawdopodobnie nie pomoże, ale kiedy nazywania zmiennych ('_start_t',' _now' ...) – Arthur

+2

@jules nie należy używać ołowiu podkreślenia [Oni nie są w globalnej przestrzeni nazw, a więc są ok.] (http://stackoverflow.com/a/228797/1171191) – BoBTFish

+2

Jakiej wersji g ++ używasz, na którym systemie operacyjnym? – Jehan

Odpowiedz

10

Prawdopodobnie używasz wersji g ++ przed wersją 4.7.0, gdzie std::chrono::steady_clock nie zostało zaimplementowane. W takim przypadku masz dwa rozwiązania:

  • Uaktualnij g ++ do wersji 4.7.0 lub nowszej.
  • Zamiast tego użyj starego std::chrono::monotonic_clock.
+0

[12:09] camill_a @/home/camill_a [4] $ g ++ -v [...] gcc wersja 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) –

+0

Jest g ++ 4.7 a szeroki używany wersja? Czy to jest stabilne? Obecnie instaluję go w ten sposób http://askubuntu.com/questions/168947/how-to-upgrade-g-to-4-7-1 –

+0

Ostatni komentarz, jakie są różnice betwin monotoniczne i stałe ? –

Powiązane problemy