diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2012-06-30 19:28:49 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2012-06-30 19:28:49 +0300 |
commit | 78086cc27d746a425f3f1130e822275bdb623090 (patch) | |
tree | e22f1c33724651abe325cdad9c25fa9c1c815184 /pb.h | |
parent | 67add3259a6429cb4afc1bdb6345e8c057a55ca8 (diff) |
Add PB_MANY_FIELDS option for supporting fields > 255.
Add generator warning if this is necessary.
Fixes issue #14.
Diffstat (limited to 'pb.h')
-rw-r--r-- | pb.h | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -22,6 +22,11 @@ #define UNUSED(x) (void)(x) #endif +/* Compile-time assertion, used for checking compatible compilation options. */ +#ifndef STATIC_ASSERT +#define STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND)?1:-1]; +#endif + /* Number of required fields to keep track of * (change here or on compiler command line). */ #ifndef PB_MAX_REQUIRED_FIELDS @@ -101,12 +106,22 @@ typedef enum { */ typedef struct _pb_field_t pb_field_t; struct _pb_field_t { + +#ifndef PB_MANY_FIELDS 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 */ +#else + uint32_t tag; + pb_type_t type; + uint8_t data_offset; + int8_t size_offset; + uint32_t data_size; + uint32_t array_size; +#endif /* Field definitions for submessage * OR default value for all other non-array, non-callback types |