协议编译器错误超出枚举值 0x88000000 的范围
protoc compiler error out of range for enum value 0x88000000
在原型文件中,我有一个枚举,就像我正在将它转换为 C++ 代码
它抛出错误 Integer out of range for field(_G,_P,_L) 。在 https://developers.google.com/protocol-buffers/docs/proto3#enum 中说 "Enumerator constants must be in the range of a 32-bit integer" 。请帮我解决这个问题
枚举字段是
pb_EnumTargetType_A = 0x40000000;
tpb_EnumTargetType_G = 0x88000000;
tpb_EnumTargetType_P = 0x8C000000;
tpb_EnumTargetType_L = 0x8A000000;
我猜它会将此解释为 正数 数字,因此需要超过 32 位才能将其编码为有符号整数。将其写成有符号整数似乎可行:
pb_EnumTargetType_A = 0x40000000;
tpb_EnumTargetType_G = -2013265920; // 0x88000000
tpb_EnumTargetType_P = -1946157056; // 0x8C000000
tpb_EnumTargetType_L = -1979711488; // 0x8A000000
在原型文件中,我有一个枚举,就像我正在将它转换为 C++ 代码 它抛出错误 Integer out of range for field(_G,_P,_L) 。在 https://developers.google.com/protocol-buffers/docs/proto3#enum 中说 "Enumerator constants must be in the range of a 32-bit integer" 。请帮我解决这个问题
枚举字段是
pb_EnumTargetType_A = 0x40000000;
tpb_EnumTargetType_G = 0x88000000;
tpb_EnumTargetType_P = 0x8C000000;
tpb_EnumTargetType_L = 0x8A000000;
我猜它会将此解释为 正数 数字,因此需要超过 32 位才能将其编码为有符号整数。将其写成有符号整数似乎可行:
pb_EnumTargetType_A = 0x40000000;
tpb_EnumTargetType_G = -2013265920; // 0x88000000
tpb_EnumTargetType_P = -1946157056; // 0x8C000000
tpb_EnumTargetType_L = -1979711488; // 0x8A000000