Another option, as i think was mentioned is to create an initialiser for the struct:
struct Error
{
byte code;
boolean active;
char msg[21];
Error(byte code_, boolean active_, char* msg_) {
code = code_;
active = active_;
strncpy(msg,msg_,21);
}
};
Error someError = Error(1,false,"some error");
You could use your errorStates struct like this:
struct ErrorStates {
Error ERR_A;
Error ERR_B;
};
ErrorStates states = {someError,Error(2,true,"some other error")}; //just an example
But it would be far easier to use if it were just this (without the second struct):
Error errorSates[] = {Error(1,false,"some error"),Error(2,true,"some other error")};
Then you could do stuff like this:
Serial.print(errorStates[1].msg); //just for example