我有这些结构:
struct menu_item{
int id;
char *text;
};
struct menu_tab{
char *label;
unsigned char item_count;
struct menu_item *items;
};
struct menu_page{
char *label;
unsigned char tab_count;
struct menu_tab *tabs;
};
struct Tmenu{
unsigned char page_count;
struct menu_page *pages;
};
我想定义整个菜单系统:
struct Tmenu menu_test = {
2,
{
"F1",
2,
{
{
"File",
8,
{
{1, "text 1"},
{2, "text2"},
{3, "text3333333"},
{4, "text4"},
{5, "Hello"},
{6, "42"},
{7, "world"},
{8, "!!!!!!!!"}
}
},
{
"File2",
3,
{
{11, "file2 text 1"},
{12, "blah"},
{13, "..."}
}
}
}
},
{
"F2",
1,
{
{
"File3",
5,
{
{151, "The Answer To Life"},
{152, "The Universe"},
{153, "and everything"},
{154, "iiiiiiiiiiiiiiiis"},
{42, "Fourty-Two"}
}
}
}
}
};
但是当我尝试编译时,我收到 extra brace group at end of initializer
错误消息。
我尝试了许多不同的方法来做到这一点,但没有一个成功。那么像这样在C中使用复杂的结构是可能的吗?