I am working with C99. My compiler is IAR Embedded workbench but I assume this question will be valid for some other compilers too.
I have a typedef enum with a few items in it and I added an element to a struct of that new type
typedef enum
{
foo1,
foo2
} foo_t;
typedef struct
{
foo_t my_foo;
...
} bar_t;
Now I want to create an instance of bar_t and initialize all of its memory to 0.
bar_t bar = { 0u };
This generates a warning that I mixing an enumerated with another type. The IAR specific warning number is Pe188. It compiles and works just fine since an enum is an unsigned int at the end of the day. But I'd like to avoid a thousand naggy warnings. What's a clean way to initialize struct types that have enumerated types in them to 0?
for the sake of argument lets assume bar_t has a lot of members - I want to just set them all to 0. I'd rather not type out something like this:
bar_t bar = { foo1, 0u, some_symbol,... , 0u};
EDIT: Extra note: I am complying with MISRA. So if a workaround is going to violate MISRA it just moves the problem for me. I'll get nagged by the MISRA checker instead.