OK, let's say that have a function menu structure declaration
like this (since I basically do):
typedef struct function_item {
char *descrip;
void(*function) (void);
} t_function_item ;
typedef struct function_menu {
unsigned short num_items;
unsigned short default_item;
char *title_prompt;
t_function_item *function_items ;
} t_function_menu ;
Now sometimes (really just about all the time) I want to initialize it to
literal values. So this is how I do it (sort of) for a local function that
selects
a function and runs it (code that doesn't illustrate the question elided):
void my_function_1(v oid) {
}
void my_function_2(v oid) {
}
unsigned short run_function_me nu(t_function_m enu *function_menu) {
}
void select_function (void) {
static t_function_menu my_function_men u=
{0,0,"My Function Menu"};
static t_function_item my_function_ite ms[]={
{"My Function 1",my_function_ 1},
{"My Function 2",my_function_ 2},
{NULL,NULL}};
my_function_men u.function_item s=my_function_i tems;
run_function_me nu(&my_function _menu);
}
My question is: for some reason if I try to initialize the menu
structure in one fell swoop, with what seems to me to be a legal
initialization, like this:
static t_function_menu my_function_men u=
{0,0,"My Function Menu",(t_functi on_item []){
{"My Function 1",my_function_ 1},
{"My Function 2",my_function_ 2},
{NULL,NULL}}};
I just get a bunch of syntax errors, but to me, the above seems
to be functionally identical to what I actually have to do as shown in
the select_function () example to get the thing to work...why am I
getting the errors, and IS there some way to initialize such a structure
in one initialization assignment? What am I missing here?
---
William Ernest Reid
like this (since I basically do):
typedef struct function_item {
char *descrip;
void(*function) (void);
} t_function_item ;
typedef struct function_menu {
unsigned short num_items;
unsigned short default_item;
char *title_prompt;
t_function_item *function_items ;
} t_function_menu ;
Now sometimes (really just about all the time) I want to initialize it to
literal values. So this is how I do it (sort of) for a local function that
selects
a function and runs it (code that doesn't illustrate the question elided):
void my_function_1(v oid) {
}
void my_function_2(v oid) {
}
unsigned short run_function_me nu(t_function_m enu *function_menu) {
}
void select_function (void) {
static t_function_menu my_function_men u=
{0,0,"My Function Menu"};
static t_function_item my_function_ite ms[]={
{"My Function 1",my_function_ 1},
{"My Function 2",my_function_ 2},
{NULL,NULL}};
my_function_men u.function_item s=my_function_i tems;
run_function_me nu(&my_function _menu);
}
My question is: for some reason if I try to initialize the menu
structure in one fell swoop, with what seems to me to be a legal
initialization, like this:
static t_function_menu my_function_men u=
{0,0,"My Function Menu",(t_functi on_item []){
{"My Function 1",my_function_ 1},
{"My Function 2",my_function_ 2},
{NULL,NULL}}};
I just get a bunch of syntax errors, but to me, the above seems
to be functionally identical to what I actually have to do as shown in
the select_function () example to get the thing to work...why am I
getting the errors, and IS there some way to initialize such a structure
in one initialization assignment? What am I missing here?
---
William Ernest Reid
Comment