I'm trying to do something which I'm sure is easily done but I can't find the right way of doing it.
I have a structure type in my code something like this:
struct mystruct{ uint8 valid; uint8 foo; uint8 bar; uint16 cats; uint32 dogs; uint8 checksum;}
which is then part of a larger structure:
struct everything{ struct otherstruct something; struct mystruct some_things[NUMBER_OF_THINGS]; ...etc.}This resides in RAM and the contents are modified by the software.
I would like to be able to "reset" the entire struct to defaults by creating a const like:
const struct mystruct default ={ valid = TRUE; foo = 0x64; bar = 10; cats = 300; dogs = 9999999; checksum = 0xFF;}
and then doing a simple one-line copy:
everything->some_things[2] = default;
Rather than having to set each individual value.
I know I can do this:
const struct mystruct default = {TRUE, 0x64, 10, 300, 9999999, 0xFF}
But it's not as readable and requires things to be in the correct order.
I'm sure I'm missing the obvious here, can anyone help?