I have this union / structure
#define HOT_INI_DATA_SIZE 14
typedef union
{
struct
{
uint8_t OVER_LOAD_TEMP_BYTE_LOW;
uint8_t OVER_LOAD_TEMP_BYTE_HI;
uint8_t TEMP_CORRECTION_BYTE_LOW;
uint8_t TEMP_CORRECTION_BYTE_HI;
uint8_t STEAM_CORRECTION_BYTE;
uint8_t LEVEL_SENSOR_CALIBR_DATA[HOT_INI_DATA_SIZE - 5];
} fields;
uint8_t bytes[HOT_INI_DATA_SIZE];
} hot_cal_data_t;
I am trying to initalise it with carious methods but have no luck:
const hot_cal_data_t initialisationHotData =
{
{0xD4},
{3},
{0},
{0},
{0},
{16, 16, 16, 16, 16, 16, 16, 16, 16 }
};
It is complaining about extra braces around initializer but when I remove it the error changes. When I try the newer C99 method:
{
{.fields.OVER_LOAD_TEMP_BYTE_LOW = 0xD4},
{.fields.OVER_LOAD_TEMP_BYTE_HI = 0x00},
...
};
it tells me the .fields is not recognized. so I have to assume that it uses the C98 method of only initializing the first union element.
Can anyone please tell me the correct syntax to get this initialized.
I have since figured it out. It is using C89 standard and requires this syntax to initialize: