admin管理员组文章数量:1122832
I have an enum in capnp declared like this:
enum Color {
red @0;
blue @1;
orange @2;
}
And I would like to add a new identifier to replace an old one without breaking the binary api (say I want the new code to manipulate yellow
instead of orange
, but not modify legacy code).
I tried this:
enum Color {
red @0;
blue @1;
orange @2;
yellow @2;
}
and this
enum Color {
red @0;
blue @1;
orange @2;
yellow = orange;
}
more or less the way I would write it in C++, but none works: the former gives error: Duplicate ordinal number
, and the later error: Parse error.
.
I did not find much on this in documentation.
So is there a way to do this with capn proto, and how?
I have an enum in capnp declared like this:
enum Color {
red @0;
blue @1;
orange @2;
}
And I would like to add a new identifier to replace an old one without breaking the binary api (say I want the new code to manipulate yellow
instead of orange
, but not modify legacy code).
I tried this:
enum Color {
red @0;
blue @1;
orange @2;
yellow @2;
}
and this
enum Color {
red @0;
blue @1;
orange @2;
yellow = orange;
}
more or less the way I would write it in C++, but none works: the former gives error: Duplicate ordinal number
, and the later error: Parse error.
.
I did not find much on this in documentation.
So is there a way to do this with capn proto, and how?
Share Improve this question asked Nov 22, 2024 at 8:06 OznOgOznOg 4,6502 gold badges28 silver badges41 bronze badges1 Answer
Reset to default 1Sorry, you cannot give the same value to two enumerants.
You could, however, define a constant that aliases a value:
const yellow :Color = orange;
But this constant won't be scoped inside the enum; it'll have to be a sibling to the type declaration.
本文标签: capnprotoHow to give the same value at two enum identifier with cap39n protoStack Overflow
版权声明:本文标题:capnproto - How to give the same value at two enum identifier with cap'n proto - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736305260a1932526.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论