显示标签为“protobuf”的博文。显示所有博文
显示标签为“protobuf”的博文。显示所有博文

2017年4月21日星期五

protobuf中set_allocate_和mutable_

都可以用于嵌套的消息使用,mutable_返回对应消息的指针,set_allocate_中传的指针必须是new出来的堆内存而不能是栈内存。

2016年3月24日星期四

解决python中使用protobuf,import xxx_pb2出错的问题

我在import xxx_pb2时遇到这样的问题:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "VoiceSession_pb2.py", line 20, in <module>
    essionProtosP\x01'
TypeError: __init__() got an unexpected keyword argument 'syntax'

原因:protoc的版本和pip install protobuf的版本不统一。
运行protoc --version和pip list | grep protobuf分别查看两者的版本,保证版本统一错误即可解决。

2016年1月19日星期二

Google's Protocol Buffers

Here is the official link.

This is an Chinese introduction of protocol buffers.

2016年1月18日星期一

Source Insight中解决C++无法解析proto文件的问题

选择Options -> Preferences...,在Languages标签中双击C++ Language,点击Custom Parsing,然后Add一个Class,如图所示:
内容如下:
Namespace    ^package\w+\([a-zA-Z0-9_]+\)
Class    ^message\w+\([a-zA-Z0-9_]+\)
点击确定,re-parse project。
正则表达式参考:link.

选择Options -> Document Options...,在C++ Source File的File filter中增加*.proto,完成。

这个方法只能将就用,遇到 :: 不能解决。

现在看来,感觉也没什么卵用,直接把proto文件编译出来就可以了。