Maybe it's an old question. But I can't seem to get computed gotos to work (or I am doing s.th. wrong).
static void *array[2] = { &&fvm_doa, &&fvm_dob, &&fvm_doc };
goto *array[1]; // -> should go to fvm_dob ???
fvm_doa:
...
fvm_dob:
...
fvm_doc:
...
Any ideas?
Thanks Andreas
"Labels as values" is a GCC extension not present in the C standard and in Pelles C compiler.
http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Labels-as-Values.html#Labels-as-Values (http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Labels-as-Values.html#Labels-as-Values)
Hi,
this way should work like you want:
You must make the right typedef for your type/types of functions!!
typedef int (__stdcall *P_Interface)(void);
int Function_doa(void)
{
return 1;
}
int Function_dob(void)
{
return 2;
}
int Function_doc(void)
{
return 3;
}
int Function_dod(void)
{
return 4;
}
FARPROC table[]=
{
Function_doa,
Function_dob,
Function_doc,
Function_dod
};
int Test(void)
{
(P_Interface)table[1](); //executes Function_dob
return 0;
};
Greetings
Seltsamuel