请考虑以下两种结构:
typedef struct {
int num_data;
char * name_data;
int data[];
} part_t;
typedef struct {
int num_parts;
char * name_parts;
part_t parts[];
} container_t;
理想情况下,我可以像这样初始化一个容器:
const container_t container = {
2,
"Name of first container",
{
{ 4, "Name of first part", { 1, 2, 3, 4 } },
{ 5, "Name of first part", { 1, 2, 3, 4, 5 } }
}
};
我的编译器说:“错误:初始化程序太多”