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

Reply via email to