You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Gianni Ambrosio <gi...@vi-grade.com> on 2018/03/13 12:02:37 UTC
c++ enum changed from v0.9.1 to v0.11.0
Dear All,
has enum generation changed from thrift v 0.9.1 to 0.11.0?
In Thrift IDL I have:
enum WidgetId
{
LAP_TIME = 0,
TRACK_MAP = 1,
TELEMETRY = 2,
G_METER = 3,
STEER = 4,
COLLISION = 5,
COUNT = 6
}
And in C++ code I used simply the "WidgetId" type. While now I get a
compiler error and it seems I have to use WidgetId::type instead of
WidgetId. Looking at the generated C++ code now I see:
struct WidgetId {
enum type {
LAP_TIME = 0,
TRACK_MAP = 1,
TELEMETRY = 2,
G_METER = 3,
STEER = 4,
COLLISION = 5,
COUNT = 6
};
};
Unfortunately I don't have the old generated code to compare it with the
new one.
I'm looking at the thrift versions changes but at the moment I didn't
find anything related to enums and C++. Nothing on Thrift documentation
either.
On the C# side the enum generations has not been changed and it is a
flat enum:
public enum WidgetId
{
LAP_TIME = 0,
TRACK_MAP = 1,
TELEMETRY = 2,
G_METER = 3,
STEER = 4,
COLLISION = 5,
COUNT = 6,
}
So, basically, I don't like the hadrcoded "type". Is there a way to
generate a flat enum also for c++ with Thrift 0.11.0? Or is there a way
to customize the generated struct name and enum name? I mean, so that I
get a Widget::Id enum in C++ generated code?
Best regards,
Gianni
Re: c++ enum changed from v0.9.1 to v0.11.0
Posted by "James E. King, III" <jk...@apache.org>.
Try using this compiler option for cpp:
pure_enums: Generate pure enums instead of wrapper classes.
- Jim
On Tue, Mar 13, 2018 at 8:02 AM, Gianni Ambrosio <
gianni.ambrosio@vi-grade.com> wrote:
> Dear All,
> has enum generation changed from thrift v 0.9.1 to 0.11.0?
>
> In Thrift IDL I have:
>
> enum WidgetId
> {
> LAP_TIME = 0,
> TRACK_MAP = 1,
> TELEMETRY = 2,
> G_METER = 3,
> STEER = 4,
> COLLISION = 5,
> COUNT = 6
> }
>
> And in C++ code I used simply the "WidgetId" type. While now I get a
> compiler error and it seems I have to use WidgetId::type instead of
> WidgetId. Looking at the generated C++ code now I see:
>
> struct WidgetId {
> enum type {
> LAP_TIME = 0,
> TRACK_MAP = 1,
> TELEMETRY = 2,
> G_METER = 3,
> STEER = 4,
> COLLISION = 5,
> COUNT = 6
> };
> };
>
> Unfortunately I don't have the old generated code to compare it with the
> new one.
> I'm looking at the thrift versions changes but at the moment I didn't find
> anything related to enums and C++. Nothing on Thrift documentation either.
>
> On the C# side the enum generations has not been changed and it is a flat
> enum:
>
> public enum WidgetId
> {
> LAP_TIME = 0,
> TRACK_MAP = 1,
> TELEMETRY = 2,
> G_METER = 3,
> STEER = 4,
> COLLISION = 5,
> COUNT = 6,
> }
>
> So, basically, I don't like the hadrcoded "type". Is there a way to
> generate a flat enum also for c++ with Thrift 0.11.0? Or is there a way to
> customize the generated struct name and enum name? I mean, so that I get a
> Widget::Id enum in C++ generated code?
>
> Best regards,
> Gianni
>
>