7

I have this structure: (namespace is java)

package/common.thrift
common.thrift
fileA.thrift

I want fileA.thrift to include both common.thrift

include ".../package/common.thrift"
include "common.thrift"

struct A {
   1: common.Something something #From first file (no error)
   2: common.SomethingElse else  #This throws error.
}

Thrift only reads content from the file specified first in order. Is there a way for this : common.thrift as common So that i can differentiate them. Or the only solution is to have different file names

phoenix
  • 717
  • 1
  • 8
  • 26

1 Answers1

7

Thrift only reads content from the file specified first in order

Not quite. But Thrift needs a prefix to access things that are included. Because the prefix is the file name, you cannot have two "common" files included without producing ambiguities.

Consequently, the answer to the question is no, you can't.

JensG
  • 13,148
  • 4
  • 45
  • 55
  • thanks! why doesnt thrift support "aliasing" in such cases. .. is there a place i can read about it ? – phoenix Sep 14 '15 at 13:38
  • 2
    I expected that question :-) no, it doesn't but that could be an awesome extension. You can try discussing that topic on the dev mailing list. At least it sounds good to me. – JensG Sep 14 '15 at 13:40
  • 1
    So the best solution in such situations is different file names... and pretty much the only solution... haha.. thanks. – phoenix Sep 14 '15 at 14:46
  • 1
    Except that I don't understand the "haha" part, you're right. But since this is open source, nobody prevents you from doing sth about it, ie. providing a patch. – JensG Sep 15 '15 at 07:48