Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

pbc无法解析C++ protobuf序列化后的字符串 #39

Closed
lovoror opened this issue Aug 21, 2014 · 2 comments
Closed

pbc无法解析C++ protobuf序列化后的字符串 #39

lovoror opened this issue Aug 21, 2014 · 2 comments

Comments

@lovoror
Copy link

lovoror commented Aug 21, 2014

C++:

tutorial::Person person;

  person.set_name("Alice");
  person.set_id(123)
 std::string stringbuffer =person:SerializeAsString();

字符传给lua
Lua:

local file = "person.pb";
protobuf.register_file(file)

result = protobuf.decode("tutorial.Person", stringbuffer)

result一直是false

@cloudwu
Copy link
Owner

cloudwu commented Aug 22, 2014

请给出序列化后的字符串。

@lovoror
Copy link
Author

lovoror commented Nov 25, 2014

是由于对文件读取以0为结尾,传递错了pb的长度导致的。谢谢云峰

@cloudwu cloudwu closed this as completed Nov 26, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants