I'm currently working on a EEprom file structure which is filled with default values while compiling. All works fine so far except for one structure and i can't seem to find the error..
typedef struct { // ===== instance parameters =====
BOOL bInstanceActive;
BYTE nInstanceGrp[4];
BYTE nEventFilter;
BYTE nEventScheme;
BYTE nEventPriority;
BYTE nShortMul;
BYTE nDoubleMul;
BYTE nRepeatMul;
BYTE nStuckMul;
BYTE nDummy[3];
} InstanceBlock;
#define DEFAULT_INSTANCE_BLOCK {1, {255,255,255,255}, 244, 0, 2, 15, 5, 10, 30, {0}}
The Types "BOOL" and "BYTE" are both unsigned char.
the different structs are then combined to one EEprom_Mapping struct (but i currently only have this one in it, all others work fine):
typedef struct {
InstanceBlock xInstance[1]; ** edited should be 1 instead of 0
} EEprom_Mapping;
#define DEFAULT_EEprom_Mapping { DEFAULT_INSTANCE_BLOCK }
It is then initialized this way:
EEprom_Mapping xEE __attribute__((section(".eeprom"))) = DEFAULT_EEprom_Mapping;
The error message is "too many initializers for 'InstanceBlock [0]'"
Thanks in advance for any help.
For your second hidden question, with 4 elements, you miss some brackets:
// Note double brackets
#define DEFAULT_EEprom_Mapping {{ DEFAULT_INSTANCE_BLOCK, DEFAULT_INSTANCE_BLOCK, DEFAULT_INSTANCE_BLOCK, DEFAULT_INSTANCE_BLOCK }}
Indeed, xInstance
is an array inside a structure, so you need brackets for initializer list of structure and brackets for initializer list of array.