2016-08-30 12 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(); 
... 

=== 편집 ===

예, 크로노 헤더를 포함했다. 프로젝트는 미리 컴파일 된 헤더가있는 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