diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-02-07 17:48:50 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-02-07 17:48:50 +0200 |
commit | e7bf063abc2ca3a46c778e0194f0e8d4ef1a5168 (patch) | |
tree | 44bf4f3613855c6756628ef3711801313438528c /generator/nanopb_generator.py | |
parent | 47b10ec0ab370475c51294707c0fe6e160046973 (diff) |
Add check for sizeof(double) == 8.
Update issue 54
Status: FixedInGit
Diffstat (limited to 'generator/nanopb_generator.py')
-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' |