hooke
hooke

Reputation: 11

How does thrift define nested structs?

For example, how to define the following structure。

struct Model {
    1:list<Model> models;
}

Such a structure compiler will report an error Type "Model" has not been defined

Upvotes: 1

Views: 776

Answers (1)

JensG
JensG

Reputation: 13411

Works perfectly, given you use a recent version, see THRIFT-2421

$ ./thrift-0.9.1 -version
Thrift version 0.9.1

$ ./thrift-0.9.1 -gen cpp ./test.thrift
[ERROR:test.thrift:2] (last token was 'Model')
Type "Model" has not been defined.

$ ./thrift-0.10.0 -version
Thrift version 0.10.0

$ ./thrift-0.10.0 -gen cpp ./test.thrift

$

PS: Most recent version at the time of writing is 0.14.1.

Upvotes: 1

Related Questions