I have two enums in my proto file which define almost the same values.
Is it possible to cut out one of them and to leave an alias to keep all the code working?
Example:
enum A {
a = 0;
b = 1;
}
enum B {
a = 0;
b = 1;
}
I want to have something like typedef in c++:
enum A {
a = 0;
b = 1;
}
typedef A B;
I haven't found this in documentation. Are there any workarounds ?
As of protobuf version 3, this is not possible.
This is an old question, but if some people are still interested, It is possible to create alias on enum with protobuf now
enum EnumAllowingAlias {
option allow_alias = true;
UNKNOWN = 0;
STARTED = 1;
RUNNING = 1;
}
enum EnumNotAllowingAlias {
UNKNOWN = 0;
STARTED = 1;
// RUNNING = 1; // Uncommenting this line will cause a compile error inside Google and a warning message outside.
}
As explained in the official documentation here. You just need to enable the alias option by adding option allow_alias = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With