【问题标题】:aws-sdk-cpp undefined type Aws::Glacier::Model::GetDataRetrievalPolicyOutcomeaws-sdk-cpp 未定义类型 Aws::Glacier::Model::GetDataRetrievalPolicyOutcome
【发布时间】:2017-07-25 02:57:28
【问题描述】:

我使用通过 NuGet 获得的 VS 2015 和 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>>'

这是我的代码:

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>

我尝试将 Aws::Glacier::Model::GetDataRetrievalPolicyOutcome 替换为 autoAws::Utils::Outcome&lt;type_of_result, type_of_error&gt; 但这没有帮助

附:我也无法创建任何类型的Aws::Utils::Outcome&lt;R,E&gt; 实例

附言当我尝试包含 #include &lt;aws/core/utils/Outcome.h&gt; 时,我收到以下错误: 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

【问题讨论】:

    标签: c++ amazon-web-services


    【解决方案1】:

    好的,当我将 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>
    

    一切都开始工作了

    【讨论】:

      猜你喜欢
      • 2017-09-02
      • 2017-08-16
      • 1970-01-01
      • 1970-01-01
      • 2018-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多