【发布时间】:2012-08-25 13:04:58
【问题描述】:
我有这些结构:
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 中使用复杂的结构是可能的吗?
【问题讨论】:
-
你是刚从 PHP 来的吗? :-)