12 MyMessage msg = MyMessage_init_zero;
16 msg.numbers_count = 3;
17 strncpy(msg.numbers[0].key,
"one",
sizeof(msg.numbers[0].key));
18 strncpy(msg.numbers[1].key,
"two",
sizeof(msg.numbers[1].key));
19 strncpy(msg.numbers[2].key,
"seven",
sizeof(msg.numbers[2].key));
20 msg.numbers[0].value = 1;
21 msg.numbers[1].value = 2;
22 msg.numbers[2].value = 7;
26 if (
pb_encode(&stream, MyMessage_fields, &msg))
MOSAPI char * strncpy(char *__restrict dest, const char *__restrict src, size_t n)
size_t fwrite(const void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream)
#define PB_GET_ERROR(stream)
pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize)
bool pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct)
#define SET_BINARY_MODE(file)