I have essentially this:
void **a;
typedef void (*ExampleFn)();
void
foo() {
puts("hello");
}
void
init() {
ExampleFn b[100] = {
foo
};
a = malloc(sizeof(void) * 10000);
a[0] = b;
}
int
main() {
init();
ExampleFn x = a[0][0];
x();
}
But when running I get all kinds of various errors, such as this:
error: subscript of pointer to function type 'void ()'
How do I get this to work?
Doing something like ((ExampleFn*)a[0])[0]();
gives a segmentation fault.