I want to initialise a const struct
:
const struct MyStruct MYSTRUCT_DEFAULTS = {
"prop1",
"prop2",
"prop3",
123,
456,
...
}
However in the above it is impossible to tell which field is which when the struct
is large. In C99 I can use { .prop1 = "prop1, ...}
syntax but I am not compiling under C99.
I don't believe I can create the struct and then use MYSTRUCT_DEFAULTS.prop1 = "prop1"
because this would violate it being const
.
Is there a neater way to initialise my struct and be clear which fields are which? I can obviously use comments next to each field but that is error prone when fields are added or removed from the struct
.