I have the following code but I am having problem to initialize. How can I initialize an array of struct with array?
typedef struct
{
UINT8_T ID;
string CN;
} CU_ContractDesc;
typedef struct
{
UINT8_T DataType;
UINT8_T DataSize;
string SignalName; //This used only for debugging
UINT8_T NrCont;
CU_ContractDesc Contracts [];
} CU_BusDesc;
CU_BusDesc BusItems[]={
{SS_SINGLE, sizeof(single_T), "S1", 1, {{99, "GV1"}}},
{SS_UINT32, sizeof(uint32_T), "S2", 1, {{99, "GV1"}, {1, "GV2"}}}
};
CU_ContractDesc Contracts[];has to have a fixed size (e.g.CU_ContractDesc Contracts[4];). Since that is probably not what you want, usestd::vector<CU_ContractDesc> Contracts;instead.C++start usingtypedefforstruct?