[英]protobuf c++ generate Message instead of MessageLite
I have some proto definitions that i want to compile to C++ headers/code. 我有一些要编译为C ++标头/代码的原型定义。 When i do, all the data types are
MessageLite
, which I understand is more light weight for resource constraint devices. 当我这样做时,所有数据类型都是
MessageLite
,据我了解,对于资源约束设备而言,它的重量更轻。
However, MessageLite
is missing a bunch of functions that i need (eg: MessageToJsonString
and SerializeToOsStream
). 但是,
MessageLite
缺少了我需要的一堆函数(例如: MessageToJsonString
和SerializeToOsStream
)。 Is there a way for protoc
to generate Message
instead of MessageLite
? 有没有办法让
protoc
生成Message
而不是MessageLite
?
Alternatively, is there a better way to work with MessageLite
? 另外,还有更好的方法与
MessageLite
吗? Namely, debugging and serializing to file? 即,调试并序列化到文件?
Look in your protobuf definition for the following line: 在protobuf定义中查找以下行:
option optimize_for = LITE_RUNTIME;
and either comment it out, or remove it. 然后将其注释掉,或将其删除。 That line is instructing protoc to use MessageLite, not Message.
该行指示协议使用MessageLite,而不是Message。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.