# Static\_assert Error in generated include file

**URL:** <https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202>\
**Category:** Libcanard\
**Created:** [April 20, 2021, 8:43pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202 "2021-04-20T20:43:54Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![alantrow](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alantrow](https://forum.opencyphal.org/u/alantrow)\
**Post date:** [April 20, 2021, 8:43pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/1 "2021-04-20T20:43:54Z")

</div>

I’m using these commands to generate my include files:

```bash
$ nnvg --target-language c --target-endianness=little --enable-serialization-asserts uavcan --outdir uavcan_messages

$ nnvg --target-language c --target-endianness=little --enable-serialization-asserts reg --lookup-dir uavcan --outdir uavcan_messages

$ nnvg --target-language c --allow-unregulated-fixed-port-id --target-endianness=little --enable-serialization-asserts fortem_msgs --lookup-dir uavcan --outdir uavcan_messages

```

Every one of my generated include files contains these types of static\_assert errors:

```auto
static_assert( NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT == 0,
              "<< MY DIRECTORY >>/directives/160.LightsCommand.1.0.uavcan is trying to use a serialization library that was compiled with "
              "different language options. This is dangerous and therefore not allowed." );

```

Does anyone have an idea what might be going wrong? “OMIT\_FLOAT\_SERIALIZATION\_SUPPORT” seems to be a hint, but I don’t know where to start looking.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![david.lenfesty](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/david.lenfesty/32/488_2.png) [@david.lenfesty](https://forum.opencyphal.org/u/david.lenfesty)\
**Post date:** [April 21, 2021, 4:07am UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/2 "2021-04-21T04:07:15Z")

</div>

What does your `serialization.h` look like?

Specifically the one I generated looks like this (with a bit of code removed, the defines are the important bit):

```auto
// UAVCAN common serialization support routines. +-+ +-+
// This file is based on canard_dsdl.h, which is part of Libcanard. | | | |
// \ - /
// AUTOGENERATED, DO NOT EDIT. ---
// o
//---------------------------------------------------------------------------------------------------------------------
// Language Options
// target_endianness: little
// omit_float_serialization_support: False
// enable_serialization_asserts: True
// enable_override_variable_array_capacity: False

// [some boilerplate here... ignoring so the post isn't huge]

static_assert(sizeof(size_t) >= sizeof(size_t),
    "The bit-length type used by Nunavut, size_t, "
    "is smaller than this platform's size_t type. "
    "Nunavut serialization relies on size_t to size_t conversions "
    "that do not lose data. You will need to regenerate Nunavut serialization support with a larger "
    "unsigned_bit_length type specified.");

#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_TARGET_ENDIANNESS 434322821
#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT 0
#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_SERIALIZATION_ASSERTS 1
#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY 0

// [the rest of the file]

```

You seem to be either not including this file (unlikely, the other asserts would be triggering as well, and you’d be getting an include error), or using the wrong version of the file. This should be in `uavcan_messages/nunavut/support/serialization.h`.

You can check to see if nunavut is generating `serialization.h` by adding the `--list-outputs` option to one of your commands. It should be generated every time you run nunavut, and if it isn’t, that may be your issue.

---

<div class="post-metadata">

**Author:** ![alantrow](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alantrow](https://forum.opencyphal.org/u/alantrow)\
**Post date:** [April 21, 2021, 3:42pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/3 "2021-04-21T15:42:10Z")

</div>

> [@david.lenfesty](#):
>
> –list-outputs

My serialization,.h starts like this:

```c
static_assert(sizeof(size_t) >= sizeof(size_t),
    "The bit-length type used by Nunavut, size_t, "
    "is smaller than this platform's size_t type. "
    "Nunavut serialization relies on size_t to size_t conversions "
    "that do not lose data. You will need to regenerate Nunavut serialization support with a larger "
    "unsigned_bit_length type specified.");

. . .

// API usage errors:
#define NUNAVUT_ERROR_INVALID_ARGUMENT 2
#define NUNAVUT_ERROR_SERIALIZATION_BUFFER_TOO_SMALL 3
// Invalid representation (caused by bad input data, not API misuse):
#define NUNAVUT_ERROR_REPRESENTATION_BAD_ARRAY_LENGTH 10
#define NUNAVUT_ERROR_REPRESENTATION_BAD_UNION_TAG 11
#define NUNAVUT_ERROR_REPRESENTATION_BAD_DELIMITER_HEADER 12

. . .

// The rest of the file

```

I started the generation sequence by sending :  
nnvg --target-language c --target-endianness=little --enable-serialization-asserts --list-outputs uavcan --outdir  
uavcan\_messages

The very last file listed in a HUGE list of .h’s was: uavcan\_messages/nunavut/support/serialization.h

Are there any obvious issues?

---

<div class="post-metadata">

**Author:** ![david.lenfesty](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/david.lenfesty/32/488_2.png) [@david.lenfesty](https://forum.opencyphal.org/u/david.lenfesty)\
**Post date:** [April 21, 2021, 4:02pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/4 "2021-04-21T16:02:19Z")

</div>

I probably should have been more specific, the important feature of `serialization.h` would be  
this define:

```auto
#define NUNAVUT_SUPPORT_LANGUAGE_OPTION_OMIT_FLOAT_SERIALIZATION_SUPPORT 0

```

If it defines this macro as anything other than 0, then we’ve found the problem, and need to figure out why it’s generating this file differently. If it is 0, then you probably need to double-check your include paths.

---

<div class="post-metadata">

**Author:** ![alantrow](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alantrow](https://forum.opencyphal.org/u/alantrow)\
**Post date:** [April 21, 2021, 4:42pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/5 "2021-04-21T16:42:51Z")

</div>

This line is in my serialization.h:

#define NUNAVUT\_SUPPORT\_LANGUAGE\_OPTION\_OMIT\_FLOAT\_SERIALIZATION\_SUPPORT 0

Please forgive a total noob, but where do I look for my include paths?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [April 21, 2021, 4:45pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/6 "2021-04-21T16:45:32Z")

</div>

> [@alantrow](#):
>
> Please forgive a total noob, but where do I look for my include paths?

I apologize for the silly question but is the assert actually triggered or are you just questioning why is it present in the generated code at all? Does the code compile?

---

<div class="post-metadata">

**Author:** ![alantrow](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alantrow](https://forum.opencyphal.org/u/alantrow)\
**Post date:** [April 21, 2021, 5:24pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/7 "2021-04-21T17:24:09Z")

</div>

The code does not compile. Assertion errors galore.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [April 21, 2021, 5:26pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/8 "2021-04-21T17:26:21Z")

</div>

> [@alantrow](#):
>
> Please forgive a total noob, but where do I look for my include paths?

What compiler/build system/IDE are you using? What did you change in your build settings to include the generated headers?

---

<div class="post-metadata">

**Author:** ![alantrow](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alantrow](https://forum.opencyphal.org/u/alantrow)\
**Post date:** [April 21, 2021, 5:30pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/9 "2021-04-21T17:30:50Z")

</div>

I’m compiling/building in an Ubuntu terminal. I have generated include files that were done by a coworker that compile and run well. He has since left the company. The instructions he left to generate the files “work”, but the generated code will not compile (assertion errors). I’m left to clean up.

---

<div class="post-metadata">

**Author:** ![alantrow](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alantrow](https://forum.opencyphal.org/u/alantrow)\
**Post date:** [April 27, 2021, 4:25pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/10 "2021-04-27T16:25:52Z")

</div>

Two more pieces of information I did not include. Versions:

$ python  
Python 2.7.17 (default, Feb 27 2021, 15:10:58)  
[GCC 7.5.0] on linux2

$ nnvg --version  
1.1.0

Are these the right versions?

---

<div class="post-metadata">

**Author:** ![alantrow](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alantrow](https://forum.opencyphal.org/u/alantrow)\
**Post date:** [April 27, 2021, 4:48pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/11 "2021-04-27T16:48:58Z")

</div>

One more piece of information that stands out. The version of generated include files that has the “static\_assert” error also has this in the header"

// Generator: nunavut-1.1.0 (serialization was enabled)

The version of generated include files that compile has this in the header:

// Generator: nunavut-0.6.4 (serialization was enabled)

Do I need to somehow downgrade versions of nunavut?

---

<div class="post-metadata">

**Author:** ![alantrow](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alantrow](https://forum.opencyphal.org/u/alantrow)\
**Post date:** [June 29, 2021, 8:19pm UTC](https://forum.opencyphal.org/t/static-assert-error-in-generated-include-file/1202/12 "2021-06-29T20:19:03Z")

</div>

I think you can close this one out. I found the issue with an older copy of serialization,h. I updated t he file and all is well. Thank you.
