2016-08-30 107 views
-1

私はVisual Studio 2015を使用してWin32プロジェクトを作成しています。私はchronoライブラリを使用しようとしましたが、それはそれを見つけることができないと言います。私はコンソールプロジェクトでchronoライブラリを使ってコードをテストしましたが、コンソールプロジェクトでは動作しましたが、Win32プロジェクトでは動作しませんでした。エラーC2039: 'chrono': 'std'のメンバーではありません

#include <chrono> 
... 
using namespace std::chrono; 

LocalDriveHeader header; 
auto durnow = system_clock::now().time_since_epoch(); 

header.version = VERSION; 
header.flags = 0x0000; 
header.sector_size = sector_size; 
header.early_time = chrono::duration_cast <milliseconds> (durnow).count(); 
... 

=== EDIT ===

はい、Iクロノヘッダを含みませんでした。 プロジェクトは、プリコンパイル済みヘッダーを含むWin32プロジェクトです。

c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(123): error C2039: 'chrono': is not a member of 'std' 
1> c:\program files (x86)\microsoft visual studio 14.0\vc\include\memory(1175): note: see declaration of 'std' 
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(123): error C2871: 'chrono': a namespace with this name does not exist 
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(126): error C2653: 'system_clock': is not a class or namespace name 
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(126): error C3861: 'now': identifier not found 
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(126): error C2228: left of '.time_since_epoch' must have class/struct/union 
1> c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(126): note: type is 'unknown-type' 
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(131): error C2653: 'chrono': is not a class or namespace name 
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(131): error C2065: 'duration_cast': undeclared identifier 
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(131): error C2065: 'milliseconds': undeclared identifier 
1>c:\users\eunbin\documents\visual studio 2015\projects\gamgeum\gamgeum\container.cpp(131): error C3536: 'durnow': cannot be used before it is initialized 
+5

ヘッダーはありますか? – Chris

+0

@ChrisStathisはい。 – user2821630

+0

完全なコードと正確なエラーを表示してください。 –

答えて

2

#include <chrono>をプリコンパイル済みヘッダーに追加しました。 #include <chrono>を実際のソースに追加すると、問題が発生する理由はわかりません...

6

ファイルの先頭に#include <chrono>がない可能性があります。 std::chrono名前空間にアクセスするには、#includeが必要です。

+1

私はを含む部分を含んでいませんでした。はい、クロノを含めましたが、まだそのエラーが発生しています。 – user2821630

関連する問題