message mess {
optional int32 No = 1;
repeated int32 IDs = 2;
}
然后我是从 java 层传到 c++层,这个 IDs 字段里,只有没有加入 0 这个数,c++层收到后都是正常的,但只要加入了 0,c++层解析出来的就不对了。
比如: IDs 字段为 [ 64,65,33,22,0 ] ,C++层再解析出来,就只有 [ 64,65,33,22 ] 了.
IDs 字段为 [ 64,65,33,22,0,22 ] ,C++层再解析出来,就变成 [ 64,65,33,22,64 ] 了
总之,只要有 0 在里面,就会很奇怪。
java 层是这么做的,通过 HIDl 接口发给 c++层。
mess proto = new mess();
proto.No = 1;
proto.IDs = new int[] {64,65,33,22,0};
String sendString = new String(mess.toByteArray(proto));
c++层是这么解析的:
std::string strProtoBuf = Obj->getProtoInfo(); //反正这里得到了,传来的字符串
mess proto;
mess.ParseFromString(strProtoBuf);
求助各位大佬,该怎么解啊