【问题标题】:DescribeStreamOutcome reported as "incomplete type"DescribeStreamOutcome 报告为“不完整类型”
【发布时间】:2017-10-08 10:54:13
【问题描述】:

我从 github 克隆了 aws-sdk-cpp,并且成功地构建了它(测试也通过了)。我没有做“make install”。我想专门编译 SDK 的 dynamodbstreams 部分,所以我在 cmake 参数中添加了 -DBUILD_ONLY="dynamodbstreams" 。我写了一个小测试代码,但由于报告未定义的 DescribeStreamOutcome 类型(“inclomplete 类型”)而无法编译。但是,它存在于它应该存在的头文件中。

cmake 版本:3.5.1,g++ 版本:5.4.0(我暂时没试过clang)

任何人都可以查看代码并指出问题所在吗?

我有以下代码:

#include "aws/core/Aws.h"
#include "aws/dynamodbstreams/DynamoDBStreamsClient.h"
#include "aws/dynamodbstreams/model/DescribeStreamRequest.h"

int main()
{
    Aws::SDKOptions options;
    Aws::InitAPI(options);

    Aws::DynamoDBStreams::DynamoDBStreamsClient client;
    Aws::DynamoDBStreams::Model::DescribeStreamRequest request;
    auto result = client.DescribeStream(request);
    if (result.IsSuccess()) {}

    Aws::ShutdownAPI(options);

    return 0;
}

有了这个 Makefile:

all: test

CFLAGS = -std=c++11 -Wall -fPIC \
-I$(SDK_SOURCE_DIR)/aws-cpp-sdk-core/include \
-I$(SDK_SOURCE_DIR)/aws-cpp-sdk-dynamodbstreams/include

LFLAGS = -shared -fPIC \
-L$(SDK_BUILD_DIR)/aws-cpp-sdk-core -laws-cpp-sdk-core \
-L$(SDK_BUILD_DIR)/aws-cpp-sdk-dynamodbstreams -laws-cpp-sdk-dynamodbstreams

test: test.o \
     $(CXX) -shared -fPIC -o $@ $^

test.o: test.cc
     $(CXX) $(CFLAGS) -c -o $@ $<

.PHONY: clean
clean:
     rm -f *.o test

制作时出现以下错误:

g++ -std=c++11 -Wall -fPIC -I/home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-core/include -I/home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-dynamodbstreams/include -c -o test.o test.cc
test.cc: In function ‘int main()’:
test.cc:12:48: error: invalid use of incomplete type ‘Aws::DynamoDBStreams::Model::DescribeStreamOutcome {aka class Aws::Utils::Outcome<Aws::DynamoDBStreams::Model::DescribeStreamResult, Aws::Client::AWSError<Aws::DynamoDBStreams::DynamoDBStreamsErrors> >}’
     auto result = client.DescribeStream(request);
                                                ^
In file included from /home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/Hash.h:19:0,
                 from /home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h:23,
                 from /home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-dynamodbstreams/include/aws/dynamodbstreams/DynamoDBStreamsClient.h:21,
                 from test.cc:2:
/home/attilacsabai/git-projects/aws-sdk-cpp/aws-cpp-sdk-core/include/aws/core/utils/crypto/HashResult.h:26:50: note: declaration of ‘Aws::DynamoDBStreams::Model::DescribeStreamOutcome {aka class Aws::Utils::Outcome<Aws::DynamoDBStreams::Model::DescribeStreamResult, Aws::Client::AWSError<Aws::DynamoDBStreams::DynamoDBStreamsErrors> >}’
         template< typename R, typename E > class Outcome;
                                                  ^
Makefile:16: recipe for target 'test.o' failed
make: *** [test.o] Error 1

但是,DescribeStreamOutcome 是在 DynamoDBStreamsClient.h 中定义的:

$ grep -i describestreamoutcome $SDK_SOURCE_DIR/aws-cpp-sdk-dynamodbstreams/include/aws/dynamodbstreams/DynamoDBStreamsClient.h | head -1
typedef Aws::Utils::Outcome<DescribeStreamResult, Aws::Client::AWSError<DynamoDBStreamsErrors>> DescribeStreamOutcome;

那你能帮帮我吗?谢谢。

【问题讨论】:

    标签: amazon-web-services amazon-dynamodb-streams aws-sdk-cpp


    【解决方案1】:

    “DescribeStreamOutcome 在 DynamoDBStreamsClient.h 中定义”语句不正确。 DynamoDBStreamsClient.h 中的那一行定义了 Outcome 实例化的别名。

    clang 给出了更简洁的错误信息:

    meow.cpp:12:26: error: implicit instantiation of undefined template 'Aws::Utils::Outcome<Aws::DynamoDBStreams::Model::DescribeStreamResult,
          Aws::Client::AWSError<Aws::DynamoDBStreams::DynamoDBStreamsErrors> >'
        auto result = client.DescribeStream(request);
                             ^
    /usr/local/include/aws/dynamodbstreams/DynamoDBStreamsClient.h:44:43: note: template is declared here
      template< typename R, typename E> class Outcome;
                                              ^
    

    你需要#include "aws/core/utils/Outcome.h"

    也许aws/dynamodbstreams/DynamoDBStreamsClient.h 应该包含Outcome.h,尽管使用 DynamoDBStreamsClient 的代码在没有它的情况下编译,只要您不调用任何返回结果的方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-25
      • 1970-01-01
      • 2012-07-02
      • 2011-07-13
      • 1970-01-01
      • 2019-12-02
      • 2016-10-06
      • 1970-01-01
      相关资源
      最近更新 更多