jonua
jonua

Reputation: 2005

Thrift include: Type has not been defined

I have a two thrift files: common.thrift, proto.thrift

content:

common.thrift

namespace java ru.domain.myserv.common

struct MyStruct {
    1: i32 val
}

service MyServ {
    1: MyStruct myStruct,
    2: i32 val
}

proto.thrift

include "common.thrift"

namespace java ru.domain.myserv.proto

typedef ru.domain.myserv.common.MyServ MyServ

struct ProtoServ {
    1: MyServ myServ
}

Next, I run the thrift generator:

thrift -r -out ../java --gen java proto.thrift

And I see an errors in console:

[ERROR:/path/proto.thrift:8] (last token was 'ru.domain.myserv.common.MyServ') Type "ru.domain.myserv.common.MyServ" has not been defined.

What I'm doing wrong?

Upvotes: 3

Views: 2641

Answers (1)

jonua
jonua

Reputation: 2005

Oh my God.

I had to specify

typedef common.MyServ MyServ

instead of

typedef ru.domain.myserv.common.MyServ MyServ

But for what then namesapace is necessary?

Upvotes: 4

Related Questions