pbc源码:https://github.com/cloudwu/pbc
https://blog.codingnow.com/2011/12/protocol_buffers_for_c.html
pbc应用例子
安装protobuf,源码:https://github.com/google/protobuf
建立protobuf文件address.proto:
syntax = "proto2";
// See README.txt for information and build instructions.
package tutorial;
option java_package = "com.example.tutorial";
option java_outer_classname = "AddressBookProtos";
message Profile {
optional string nick_name = 1;
optional string icon = 2;
}
message Person {
required string name = 1;
required int32 id = 2; // Unique ID number for this person.
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
required string number = 1;
optional PhoneType type = 2 [default = HOME];
}
repeated PhoneNumber phone = 4;
repeated int32 test = 5 [packed=true];
optional Profile profile = 6;
extensions 10 to max;
}
m

本文介绍了pbc库的应用,提供了源码分析链接以及protobuf的安装教程。通过创建protobuf文件`address.proto`,生成C文件`addressbook.c`,并编译执行,展示了如何使用pbc处理protobuf数据。
最低0.47元/天 解锁文章
7226

被折叠的 条评论
为什么被折叠?



