I have a struct like this:
struct Program {
unsigned int duration;
unsigned int speed;
byte orientation;
byte mode;
};
And then I want to do something like this:
struct Program currentProgram = { .duration = 3 };
The way I understand it, this should initialize duration to 3, but leave the other values at their default values (0). I know I can initialize a struct the normal way using the constructor, but then I need to specify all parameters. That's what I'm trying to avoid.
But I get this:
In function 'void loop()':
expected primary-expression before '.' token
braces around initializer for non-aggregate type 'Program'
I know that designated initializers are a C99 feature and for example not supported in Visual Studio C++. But some quick googleing suggests that AVR gcc should be able to do it. For example:
http://www.nongnu.org/avr-libc/user-manual/group__avr__fuse.html
Or am I just mangling the syntax here?