diff options
-rw-r--r-- | generator/nanopb_generator.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index d35a4252..48239c18 100644 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -512,6 +512,7 @@ def generate_header(dependencies, headername, enums, messages): yield ' setting PB_MAX_REQUIRED_FIELDS to %d or more.\n' % largest_count yield '#endif\n' + # Add checks for numeric limits worst = 0 worst_field = '' checks = [] @@ -549,6 +550,20 @@ def generate_header(dependencies, headername, enums, messages): yield 'STATIC_ASSERT((%s), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_%s)\n'%(assertion,msgs) yield '#endif\n' + # Add check for sizeof(double) + has_double = False + for msg in messages: + for field in msg.fields: + if field.ctype == 'double': + has_double = True + + if has_double: + yield '\n' + yield '/* On some platforms (such as AVR), double is really float.\n' + yield ' * These are not directly supported by nanopb, but see example_avr_double.\n' + yield ' */\n' + yield 'STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES)\n' + yield '\n#ifdef __cplusplus\n' yield '} /* extern "C" */\n' yield '#endif\n' |