Hi all,

I used the c bindings of Google protocol buffer, when use the get packed 
size method, it gave me "assertion failed" problem.

The "kvstr.proto" file:
message KVStr
    optional int32 job_id = 1;
    optional int32 num_item = 2;
    repeated string name = 3;

I generated the head file and source file, kvstr.pb-c.h, kvstr.pb-c.c

I defined a function in my program which does initialization:

extern KVStr* _init_kv_str(int has_job_id, int job_id,
int has_num_item, int num_item, int n_name)
KVStr kv_str = KVSTR__INIT;
kv_str.has_job_id = has_job_id;
if (has_job_id)
kv_str.job_id = job_id;
kv_str.has_num_item = has_num_item;
if (has_num_item)
kv_str.num_item = num_item;
kv_str.n_name = n_name;
kv_str.name = (char**)malloc(sizeof(char*) * n_name);
return &kv_str;
Then, when I do: 
KVStr* kv_str_key = _init_kv_str(0, -1, 0, -1, 1)
unsigned len = kvstr__get_packed_size(kv_str_key);

This gave me the problem:  kvstr.pb-c.c:18: kvstr__get_packed_size: 
Assertion `message->base.descriptor == &kvstr__descriptor' failed.

Does anyone know what is perhaps the problem? Thanks


You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to