diff options
Diffstat (limited to 'pb.h')
-rw-r--r-- | pb.h | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -33,6 +33,11 @@ #define PB_MAX_REQUIRED_FIELDS 64 #endif +#if PB_MAX_REQUIRED_FIELDS < 64 +#warning You should not lower PB_MAX_REQUIRED_FIELDS from the default value (64). \ + The automatic checks against too low value will not be active. +#endif + /* List of possible field types. These are used in the autogenerated code. * Least-significant 4 bits tell the scalar type * Most-significant 4 bits specify repeated/required/packed etc. @@ -99,21 +104,29 @@ typedef enum { /* This structure is used in auto-generated constants * to specify struct fields. - * You can change field sizes here if you need structures + * You can change field sizes if you need structures * larger than 256 bytes or field tags larger than 256. * The compiler should complain if your .proto has such - * structures ("initializer too large for type"). + * structures. Fix that by defining PB_FIELD_16BIT or + * PB_FIELD_32BIT. */ typedef struct _pb_field_t pb_field_t; struct _pb_field_t { -#ifndef PB_MANY_FIELDS +#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) uint8_t tag; pb_type_t type; uint8_t data_offset; /* Offset of field data, relative to previous field. */ int8_t size_offset; /* Offset of array size or has-boolean, relative to data */ uint8_t data_size; /* Data size in bytes for a single item */ uint8_t array_size; /* Maximum number of entries in array */ +#elif defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) + uint16_t tag; + pb_type_t type; + uint8_t data_offset; + int8_t size_offset; + uint16_t data_size; + uint16_t array_size; #else uint32_t tag; pb_type_t type; |