thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Slee <>
Subject RE: Dependencies
Date Wed, 27 May 2009 03:17:03 GMT
This is a known limitation. Thrift does not allow forward declarations. Forward declarations
require using pointers and having all Thrift structs be nullable.

This code couldn't be compiled into C++, because the data members of Thrift structs in C++
are true value members, not pointers or references.

It looks like what you really want here might be something more like this:

struct TCritic {
1: i32 id,
2: i32 author_id, // the ID of the author, not the actual object
3: i32 rating,
4: string text

Similarly, you might want to just store a list of critic_ids in the TAccount.

-----Original Message-----
From: Kristinn Örn Sigurðsson [] 
Sent: Tuesday, May 26, 2009 7:59 PM
Subject: Dependencies

Hi all.
I'm having a little trouble with dependencies in Thrift. See this for an

struct TAccount {
1: i32 id,
2: string email,
3: string name,
4: string password,
5: list<TPhone> phones,
6: string address,
7: string postalCode,
8: string city,
9: string country,
10: list<TCritic> critics

struct TCritic {
1: i32 id,
2: TAccount author,
3: i32 rating,
4: string text

struct TCompany {
1: i32 id,
2: string name,
3: string email,
4: string phone,
5: string address,
6: string postalCode,
7: string city,
8: string country,
9: list<TAccount> employees,
10: list<TCritic> critics

This is just a partial copy/paste. Some structs aren't shown here.

This doesn't compile into Thrift files. The problem here is that TAccount
depends on TCritic and TCritic depends on TAccount. The thing is that
structs can't see other structs that are defined after (below) them. Is
there a workaround for this?

Thanks in advance.


View raw message