2017-07-24 77 views
0

我使用VS 2015和通過NuGet獲得的aws-sdk-cpp 1.1.16(Core版本)。 當我嘗試編譯我的程序,我得到以下錯誤: Error C2027 use of undefined type 'Aws::Utils::Outcome<Aws::Glacier::Model::GetDataRetrievalPolicyResult,Aws::Client::AWSError<Aws::Glacier::GlacierErrors>>'aws-sdk-cpp undefined type Aws :: Glacier :: Model :: GetDataRetrievalPolicyOutcome

這是我的代碼:

的main.cpp

#include "stdafx.h" 

int main() 
{ 
    Aws::SDKOptions options; 
    Aws::InitAPI(options); 
    { 
     Aws::Client::ClientConfiguration config; 
     config.scheme = Aws::Http::Scheme::HTTPS; 
     config.connectTimeoutMs = 30000; 
     config.requestTimeoutMs = 30000; 
     config.region = Aws::String(Aws::Region::EU_WEST_1); 

     Aws::Glacier::GlacierClient client(config); 
     Aws::Glacier::Model::GetDataRetrievalPolicyRequest request; 
     Aws::Glacier::Model::GetDataRetrievalPolicyOutcome outcome = client.GetDataRetrievalPolicy(request); 
     //^^^ error at this line 
     if (outcome.IsSuccess()) { 
      Aws::Vector<Aws::Glacier::Model::DataRetrievalRule> rules = outcome.GetResult().GetPolicy().GetRules(); 
      for (auto it : rules) { 
       std::cout << it.GetStrategy() << std::endl; 
      } 
     } 
     else { 
      std::cout << "GetDataRetrievalPolicy error: " 
       << outcome.GetError().GetExceptionName() << std::endl 
       << outcome.GetError().GetMessage() << std::endl; 
     } 
    } 
    Aws::ShutdownAPI(options); 
    system("pause"); 
    return 0; 
} 

的stdafx.h

#pragma once 

#include <stdio.h> 
#include <tchar.h> 
#include <iostream> 

#include <aws/acm/ACMClient.h> 
#include <aws/core/Aws.h> 
#include <aws/core/Region.h> 
#include <aws/core/client/ClientConfiguration.h> 
#include <aws/core/client/AWSClient.h> 
#include <aws/glacier/GlacierClient.h> 
#include <aws/glacier/model/GetDataRetrievalPolicyRequest.h> 
#include <aws/glacier/model/GetDataRetrievalPolicyResult.h> 
#include <aws/glacier/model/DataRetrievalPolicy.h> 
#include <aws/glacier/model/DataRetrievalRule.h> 

我已試圖用autoAws::Utils::Outcome<type_of_result, type_of_error>替換Aws::Glacier::Model::GetDataRetrievalPolicyOutcome,但這樣做沒有幫助

P.S.我也不能創建任何類型的Aws::Utils::Outcome<R,E>的任何實例

P.P.S.當我試圖包括#include <aws/core/utils/Outcome.h>我收到以下錯誤: Error C2535 'Aws::Utils::Outcome<std::string,std::string>::Outcome(R &&)': member function already defined or declared ..\packages\awssdkcpp-core.1.1.16\build\native\include\aws\core\utils\outcome.h 50
Error C2535 'Aws::Utils::Outcome<std::string,std::string>::Outcome(const R &)': member function already defined or declared ..\packages\awssdkcpp-core.1.1.16\build\native\include\aws\core\utils\outcome.h 44

回答

0

好吧,當我改變stdafx.h中,以

#pragma once 

#include <stdio.h> 
#include <tchar.h> 
#include <iostream> 

#include <aws/core/Aws.h> 
#include <aws/glacier/GlacierClient.h> 
#include <aws/glacier/model/GetDataRetrievalPolicyRequest.h> 
#include <aws/core/utils/Outcome.h> 

一切都開始工作

相關問題