Код: Выделить всё
syntax = "proto3";
package package;
message WriteBlock
{
uint32 address = 1;
uint32 size = 2;
bytes data = 3;
}
Код: Выделить всё
package_WriteBlock writeBlock = package_WriteBlock_init_zero;
В документации сказано, что тип байты будет преобразован в строку. Если я проверю свой перевод:
Код: Выделить всё
typedef struct _package_ReadAgg {
uint32_t address;
uint32_t size;
pb_callback_t data;
} package_ReadAgg;
Код: Выделить всё
typedef struct pb_callback_s pb_callback_t;
struct pb_callback_s {
/* Callback functions receive a pointer to the arg field.
* You can access the value of the field as *arg, and modify it if needed.
*/
union {
bool (*decode)(pb_istream_t *stream, const pb_field_t *field, void **arg);
bool (*encode)(pb_ostream_t *stream, const pb_field_t *field, void * const *arg);
} funcs;
/* Free arg for use by callback */
void *arg;
};
Я не нашел объяснения, как заполнять такие вещи :/
Подробнее здесь: https://stackoverflow.com/questions/787 ... protobuf-c