I found a similiar answer to my problem here. But it is not working the way I expected.
So I have
void funcA(void) {
// do sth.
}
void funcB(void) {
// do sth.
}
typedef struct tasks {
int val;
void (*Start)(void);
} tasks;
and
const tasks tasklist[] =
{
{0, funcA},
{3, funcB}
};
for (i=0; i < task_cnt; i++ )
if (tasklist[i].val == 3)
tasklist[i]->Start();
But at “…->Start();” compiler says “expression must have pointer type”.
Any ideas?
Thanks
You access
Startthe same way you accessval— with a dot:tasklist[i].Start().