How do I set a int32
to use a fixed size for encoding?
In the API, it says
PB_LTYPE_FIXED32 0x04 32-bit integer or floating point.
But what option do I set in the .proto
file to encode a int32
as a PB_LTYPE_FIXED32
as opposed to a PB_LTYPE_VARINT
?
In the function encode_basic_field
the fields
structure, which is autogenerated, stores the field type which means that this information is set in .proto
file somehow.
I think you should try "int32_t" instead of int32.
please check the "nanopb" project, in the file "nanopb_generator.py", there is a dictionary called "datatypes", here is some code:
FieldD.TYPE_FIXED32: ('uint32_t', 'FIXED32', 4, 4),
FieldD.TYPE_SFIXED32: ('int32_t', 'SFIXED32', 4, 4),
because it's my first time to see the "nanopb" project, I'm not 100% sure whether it will work or not.