5

I'm a newbie with Thrift. I have the following question: Suppose that I defined a struct in file "Ex1.thrift" as follow:

namespace java tut1
struct Address {
 1:string nameStreet,
 2:i32 idHouse
}

I want to use struct Address in file "Ex2.thrift", how could I do that? I tried this way but Thrift compiler doesn't work:

include "Ex1.thrift"
namespace java tut2
struct Student {
 1:string name,
 2:i32 age,
 3:Address add
}

service ExampleService {
 list<Student> getListStudent()
}

Thank you so much for any answer.

JensG
  • 13,148
  • 4
  • 45
  • 55
zungnv
  • 257
  • 3
  • 11

1 Answers1

13

You need to provide Ex1 prefix while using address in Ex2.thrift

    include "Ex1.thrift"
    namespace java tut2
    struct Student {
    1:string name,
    2:i32 age,
    3:Ex1.Address add
    }

    service ExampleService {
    list<Student> getListStudent()
    }

This works in Thrift 0.8.0

gt5050
  • 561
  • 6
  • 12